Get changes in to-do list in Sharepoint Online via PowerShell

I am trying to figure out the changes made to a task list in sharepoint online using CSOM. (Microsoft.SharePoint.Client.dll) I was able to request changes using the GetChanges method of the List class, but I'm not sure what to do next. I'm specifically looking for how to get information related to changes to lists in specific columns, old values, new values, the user who made the change, etc. Is it possible? I know the Change.ChangeToken property, but I'm not sure how to implement it in PowerShell. Here is my incomplete code:

[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-ListChanges {   
    $listName = "Tasks"
    $list = $clientContext.Web.Lists.GetByTitle($listName)
    $cq = new-object Microsoft.Sharepoint.Client.ChangeQuery($true,$true)
    $changes = $list.GetChanges($cq)
    $clientContext.Load($changes)
    $clientContext.ExecuteQuery()
    $changes.count
    foreach ($item in $changes) {   
        # get data here from specific column name/old values/newvalues
    }   
}

      

Thank you for this!

UPDATE: As requested, the result of $ item.GetType () for one change item ...

Module                     : System.Management.Automation.dll
Assembly                   : System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
TypeHandle                 : System.RuntimeTypeHandle
DeclaringMethod            :
BaseType                   : System.Object
UnderlyingSystemType       : System.Management.Automation.PSCustomObject
FullName                   : System.Management.Automation.PSCustomObject
AssemblyQualifiedName      : System.Management.Automation.PSCustomObject, System.Management.Automation, Version=3.0.0.0, Culture=neutral
                             PublicKeyToken=31bf3856ad364e35
Namespace                  : System.Management.Automation
GUID                       : 5f6aa156-8585-35c9-a6ae-2aefd06aaa4a
IsEnum                     : False
GenericParameterAttributes :
IsSecurityCritical         : True
IsSecuritySafeCritical     : False
IsSecurityTransparent      : False
IsGenericTypeDefinition    : False
IsGenericParameter         : False
GenericParameterPosition   :
IsGenericType              : False
IsConstructedGenericType   : False
ContainsGenericParameters  : False
StructLayoutAttribute      : System.Runtime.InteropServices.StructLayoutAttribute
Name                       : PSCustomObject
MemberType                 : TypeInfo
DeclaringType              :
ReflectedType              :
MetadataToken              : 33554762
GenericTypeParameters      : {}
DeclaredConstructors       : {Void .cctor(), Void .ctor()}
DeclaredEvents             : {}
DeclaredFields             : {SelfInstance}
DeclaredMembers            : {System.String ToString(), Void .cctor(), Void .ctor(), SelfInstance}
DeclaredMethods            : {System.String ToString()}
DeclaredNestedTypes        : {}
DeclaredProperties         : {}
ImplementedInterfaces      : {}
TypeInitializer            : Void .cctor()
IsNested                   : False
Attributes                 : AutoLayout, AnsiClass, Class, Public, BeforeFieldInit
IsVisible                  : True
IsNotPublic                : False
IsPublic                   : True
IsNestedPublic             : False
IsNestedPrivate            : False
IsNestedFamily             : False
IsNestedAssembly           : False
IsNestedFamANDAssem        : False
IsNestedFamORAssem         : False
IsAutoLayout               : True
IsLayoutSequential         : False
IsExplicitLayout           : False
IsClass                    : True
IsInterface                : False
IsValueType                : False
IsAbstract                 : False
IsSealed                   : False
IsSpecialName              : False
IsImport                   : False
IsSerializable             : False
IsAnsiClass                : True
IsUnicodeClass             : False
IsAutoClass                : False
IsArray                    : False
IsByRef                    : False
IsPointer                  : False
IsPrimitive                : False
IsCOMObject                : False
HasElementType             : False
IsContextful               : False
IsMarshalByRef             : False
GenericTypeArguments       : {}
CustomAttributes           : {}

      

+3


source to share


1 answer


Tank, you can get the change type and change time:

$item | Select ChangeType,Time

      



I can take a hit in the dark, but you can look into the ChangeLogItemQuery class. It might be able to provide you with more information about the actual change itself (Old / New, etc.). Please correct me if I am wrong.

More information about the ChangeLogItemQuery class: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.changelogitemquery_members(v=office.15).aspx

+1


source







All Articles