首页 > 解决方案 > 谁最后使用 Powershell 查询修改了文档 (Sharepoint)

问题描述

我需要打印一份报告,显示谁编辑了文档,下面是我正在使用的代码。的输出结果:

“由选项 1 修改”是 Microsoft.SharePoint.Client.User
“由选项 2 修改”是 Microsoft.SharePoint.Client.FieldUserValue
What am I missing?
    #Get the web & Library
        $Web=$Ctx.Web
        $Ctx.Load($Web)
        $List = $Web.Lists.GetByTitle($LibraryName)
        $Ctx.ExecuteQuery()

        #Get All Files of from the document library - Excluding Folders
        $Query =  New-Object Microsoft.SharePoint.Client.CamlQuery
        $Query.ViewXml = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy></Query></View>"
        $ListItems=$List.GetItems($Query)
        $Ctx.Load($ListItems)
        $Ctx.ExecuteQuery()

        $VersionHistoryData = @()
        #Iterate throgh each version of file
        Foreach ($Item in $ListItems)
        {
            $File = $Web.GetFileByServerRelativeUrl($Item["FileRef"])
            $Ctx.Load($File)
            $Ctx.Load($File.ListItemAllFields)
            $Ctx.Load($File.Versions)

            $Ctx.ExecuteQuery()


                #Send Data to object array
                $VersionHistoryData += New-Object PSObject -Property @{
                'daysSinceModified' =$daysSinceModified
                'File Name' = $File.Name
                'URL' = $FileURL
                'Modified by Option 1' = $File.ModifiedBy
                'Modified by Option 2' = $Item["Editor"]
                }
            }
        }

    }

标签: powershellsharepoint-2013sharepoint-online

解决方案


使用 '修改者' = $Item["Editor"].LookupValue

返回用户短名称,例如:John Smith


推荐阅读