【问题标题】:Get changes in a Task List in Sharepoint Online through PowerShell通过 PowerShell 在 Sharepoint Online 中的任务列表中获取更改
【发布时间】:2015-01-26 12:25:51
【问题描述】:

我正在尝试在 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           : {}

【问题讨论】:

  • 您能否发布此类更改项的类型 ($item.getType()),以便我们查看属性?
  • @Paul 看到上面的变化

标签: powershell sharepoint sharepoint-2013 powershell-3.0 sharepoint-online


【解决方案1】:

坦克,可以获取更换类型和更换时间:

$item | Select ChangeType,Time

我可能会在黑暗中冒险,但您可能想调查 ChangeLogItemQuery 类。它可能能够为您提供有关实际更改本身(旧/新等)的更多信息。如果我错了,请纠正我。

这里有关于 ChangeLogItemQuery 类的更多信息: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.changelogitemquery_members(v=office.15).aspx

【讨论】:

    猜你喜欢
    • 2014-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-04
    相关资源
    最近更新 更多