我试图在CSOM的帮助下找出在sharepoint中对任务列表所做的更改。 (Microsoft.SharePoint.Client.dll)我能够通过List类的GetChanges方法查询更改,但不知道该怎么做。我特别想知道如何获取与特定列中的列表更改相关的信息,旧值,新值,进行更改的用户等。这是否可能?我知道Change.ChangeToken属性,但我不知道如何在PowerShell中实现它。这是我不完整的代码:
[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
}
}
感谢您参与此活动!
更新: 根据要求,$ item.GetType()的结果为单个更改项目...
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 : {}
答案 0 :(得分:1)
坦克,可以获得更改类型和更改时间:
$item | Select ChangeType,Time
我可能会在黑暗中捅,但您可能想要研究ChangeLogItemQuery类。它可能能够为您提供有关实际更改本身的更多信息(旧/新等)。如果我错了,请纠正我。
有关ChangeLogItemQuery类的更多信息: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.changelogitemquery_members(v=office.15).aspx