簡體   English   中英

通過PowerShell在Sharepoint Online中獲取任務列表中的更改

[英]Get changes in a Task List in Sharepoint Online through PowerShell

我試圖在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           : {}

Tank,可以獲得更改類型和更改時間:

$item | Select ChangeType,Time

我可能會在黑暗中進行攻擊,但您可能想要研究ChangeLogItemQuery類。 它可能能夠為您提供有關實際更改本身的更多信息(舊/新等)。 如果我錯了,請糾正我。

有關ChangeLogItemQuery類的更多信息,請訪問: https ://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.changelogitemquery_members( v= office.15).aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM