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.
[Reflection.Assembly]::LoadFrom("$scriptdir\Microsoft.SharePoint.Client.dll")
$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
$context.Load($web)
$context.Load($site)
$context.ExecuteQuery()
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)
$clientContext.Load($col)
$clientContext.ExecuteQuery()
$col.count
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