I have the following powershell:
$list = $ctx.Web.Lists.GetByTitle("Documents")
$ctx.Load($list)
$ctx.ExecuteQuery()
## View XML
$qCommand = @"
<View>
<Query>
<Where><Eq><FieldRef Name='ContentType'/><Value Type='Text'>Folder</Value></Eq></Where>
<OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>
</Query>
<RowLimit Paged="TRUE">5000</RowLimit>
</View>
"@
## Page Position
$position = $null
## All Items
$allItems = @()
Do{
$camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
$camlQuery.ListItemCollectionPosition = $position
$camlQuery.ViewXml = $qCommand
## Executing the query
$currentCollection = $list.GetItems($camlQuery)
$ctx.Load($currentCollection)
$ctx.ExecuteQuery()
## Getting the position of the previous page
$position = $currentCollection.ListItemCollectionPosition
# Adding current collection to the allItems collection
$allItems += $currentCollection
}
# the position of the last page will be Null
Until($position -eq $null)
$results = ""
foreach($item in $allItems){
write-host $item["Name"]
$item.Name | Out-File "C:\temp\test.csv" -append
}
Which should output the name of each folder, however it is just a blank line. I have tested the script with outputting the ID and that matches with the folders that are in the library it is just an issue when i try outputting the Name. Any ideas where i am going wrong?