powershell - 谁最后使用 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"]
}
}
}
}
解决方案
使用 '修改者' = $Item["Editor"].LookupValue
返回用户短名称,例如:John Smith
推荐阅读
- autohotkey - 我是哑巴吗?自动热键脚本的这一行有什么问题
- python - 在字符串变量中添加换行符
- html - 哪种 Web Scraping 提取方法更好?
- c - 有什么方法可以降低下面给出的函数的时间复杂度?
- react-native - 嗨,我是 React Native 的新手,使用 Native-base 我正在尝试设计卡片视图
- javascript - 媒体查询中的某些内容不起作用
- python - 如何使用带有精灵的图像字典?
- python - numpy数组的异常重塑
- c++ - 可重现的可执行文件。什么控制入口点地址?
- mysql - 关注者/关注者的 NoSQL VS RDB