function GetOnetoc2($WebDomain,$web,$ctx,$List,$SummaryOuputFile)
{
#Prepare the CAML query
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$Query.ViewXml = "@
<View Scope='RecursiveAll'>
<Query>
<Where>
<Eq>
<FieldRef Name='File_x0020_Type' /><Value Type='Text'>Onetoc2</Value>
</Eq>
</Where>
</Query>
<RowLimit>3000</RowLimit>
</View>"
$FileCount=0
#Batch Process List items
Do {
try
{
$ListItems = $List.GetItems($Query)
$Ctx.Load($ListItems)
$Ctx.ExecuteQuery()
$Query.ListItemCollectionPosition = $ListItems.ListItemCollectionPosition
$FileCount=$FileCount + $ListItems.count
If($ListItems.count -gt 0)
{
ForEach($Item in $ListItems)
{
$Fileoutput = $output + "," + $($WebDomain+$item["FileRef"])
Add-Content $SummaryOuputFile $Fileoutput
}
}
}catch
{
$e = $_.Exception
$line = $_.InvocationInfo.ScriptLineNumber
$msg = $e.Message
Write-Host -ForegroundColor Red "caught exception: $e at $line"
}
}While($Query.ListItemCollectionPosition -ne $Null)
Return $FileCount
}