I am retrieving a change log for SharePoint Online site, but I am particularly interested in the who performed the change and on what item.

$changeQuery = New-Object Microsoft.SharePoint.Client.ChangeQuery $true,$true
$changeCollection = $ctx.Site.GetChanges($changeQuery)

I found this post, but when I export my changes to a csv, in Excel I don't see ItemId or UserId. I see those properties in the Powershell window as the script runs.

The Excel file looks like it looks, because not all elements include those properties. The columns in Excel come from the properties of the first retrieved item. Fine. I tried to use a rather clumsy workaround, by half-manually adding those properties to elements if they are not there:

foreach ($change in $changeCollection)
$change | Add-Member ItemName("Not Applicable")
$change | Add-Member ListName("Not Applicable")

if(-Not $change.IsPropertyAvailable("ItemId")) { $change | Add-Member ItemId("Not Applicable")} else { $change["ItemName"]=$ctx.Web.Lists.GetById($change.ListId).GetItemById($change.ItemId).LeafName}
if(! $change.IsPropertyAvailable("ListId")) { $change | Add-Member ListId("Not Applicable")}

Write-Output $change

but I am receiving an error:

Unable to index into an object of type Microsoft.SharePoint.Client.ChangeItem. At C:\Users\ivo\Desktop\wiki\technet\changecollection.ps1:53 char:104 + if(-Not $change.IsPropertyAvailable("ItemId")) { $change | Add-Member ItemId("No ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : CannotIndex

Questions: (answer to any of them will solve my trouble)
How to check if the property is available?
How to export to csv a jagged array/items with varied properties?

Of course any other more enlightened solution is most welcome.

  • Thanks the upvoter, but it never bides well when I get more upvotes than answers...
    – grisha
    Commented Mar 13, 2015 at 11:29

1 Answer 1


After error analysis I found out that the error was caused by calling improperly the item property. Item[Property] instead of Item.Property

Little things make you happy :) Please find below the working code as jagged array seems not to be a feasible solution:

if(! $change.IsPropertyAvailable("ItemId")) { $change | Add-Member ItemId("Not Applicable")} else { 
if(! $change.IsPropertyAvailable("ListId")) { $change | Add-Member ListId("Not Applicable")}else { $change.ListName=$ctx.Web.Lists.GetById($change.ListId).Title}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.