I am using CSOM library through Powershell to get a list of changes made to a list in Sharepoint Online. I am stuck while creating an object for the changecollection. Not sure how to get the data that comes from GetChanges. It doesn't return anything right now.

$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$context.RequestTimeOut = 1000 * 60 * 10;
$context.AuthenticationMode = [Microsoft.SharePoint.Client.ClientAuthenticationMode]::Default
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
$context.Credentials = $credentials
$web = $context.Web  
$site = $context.Site
Set-Variable -Name "clientContext" -Value $context -Scope Global
Set-Variable -Name "rootSiteUrl" -Value $siteURL -Scope Global
Function Get-CQList {   
    $listName = "Tasks"
    $list = $clientContext.Web.Lists.GetByTitle($listName)
    $cq = new-object Microsoft.Sharepoint.Client.ChangeQuery($true,$true)
    $col = new-object Microsoft.Sharepoint.Client.ChangeCollection  #returns "Constructor not found. Cannot find an appropriate constructor for type Microsoft.Sharepoint.Client.ChangeCollection"
    $col = $list.GetChanges($cq)
    foreach ($item in $col) {   
        # get data here from specific column name/row

Thank you for looking in to this!

UPDATE: I was able to get the output from GetChanges property. I had to add $clientContext.Load($col) after calling GetChanges. See the changes above. Now trying to figure out how to get the details for the changes made. The only output I get is this:

ListId             : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WebId              : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ChangeToken        : Microsoft.SharePoint.Client.ChangeToken
ChangeType         : Add
SiteId             : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Time               : 11/4/2014 10:11:22 PM
Context            : Microsoft.SharePoint.Client.ClientContext
Tag                :
Path               :
ObjectVersion      :
ServerObjectIsNull : False
TypedObject        : Microsoft.SharePoint.Client.ChangeList

1 Answer 1



$listTitle = "Tasks"
$list = $context.Web.Lists.GetByTitle($listTitle)
$qry = new-object Microsoft.Sharepoint.Client.ChangeQuery($true,$true)
$changes = $list.GetChanges($qry)
$changes | select ChangeType, Time
  • Thanks Vadim. I just noticed that the Load method was missing. And yes I removed the ChangeCollection instance. How do I get details about the change that happened? Like the specific item that changed? (Like the old values and the new values? or column names?)
    – A. Tank
    Commented Nov 26, 2014 at 23:15
  • 1
    For that purpose use Change.ChangeToken property that specifies a change token that identifies the changed object msdn.microsoft.com/en-us/library/… Commented Nov 26, 2014 at 23:25
  • Vadim, Do I have to change the query or have to create a new Change object? Can you give me an example?
    – A. Tank
    Commented Nov 27, 2014 at 1:14
  • hey Vadim, can you give me an example of the Change.ChangeToken? I am having a hard time figuring out how ChangeTokens work and getting the new/old values and other information I want out of the list. Thanks!
    – A. Tank
    Commented Dec 15, 2014 at 20:38
  • Hey! Found your new question, sure, will post a more detailed example some later today ;) Commented Dec 16, 2014 at 14:29

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.