通过PowerShell获取Sharepoint Online中任务列表中的更改
我正试图在CSOM的帮助下找出对sharepoint online中的任务列表所做的更改。(Microsoft.SharePoint.Client.dll)我可以通过List类的GetChanges方法查询更改,但不确定进一步做什么。我特别想了解如何获得与特定列中的列表更改、旧值、新值、进行更改的用户等相关的信息。这可能吗?我知道Change.ChangeToken属性,但不确定如何在PowerShell中实现它。这是我不完整的代码:通过PowerShell获取Sharepoint Online中任务列表中的更改,powershell,sharepoint,sharepoint-2013,powershell-3.0,sharepoint-online,Powershell,Sharepoint,Sharepoint 2013,Powershell 3.0,Sharepoint Online,我正试图在CSOM的帮助下找出对sharepoint online中的任务列表所做的更改。(Microsoft.SharePoint.Client.dll)我可以通过List类的GetChanges方法查询更改,但不确定进一步做什么。我特别想了解如何获得与特定列中的列表更改、旧值、新值、进行更改的用户等相关的信息。这可能吗?我知道Change.ChangeToken属性,但不确定如何在PowerShell中实现它。这是我不完整的代码: [Reflection.Assembly]::LoadFro
[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 : {}
储罐,可以获得更换类型和更换时间:
$item | Select ChangeType,Time
我可能是在暗中摸索,但您可能想研究ChangeLogItemQuery类。它可能会为您提供有关实际更改本身(旧/新等)的更多信息。如果我错了,请纠正我
有关ChangeLogItemQuery类的更多信息,请单击此处:
您能发布这样一个变更项目的类型(
$item.getType()
)吗?这样我们就可以查看属性了吗?@Paul请参见上面的变更