sharepoint - 如何检索在站点中进行最后修改的用户
问题描述
我必须使用 Power Shell 脚本检索在给定 Web 中进行最后修改的用户的名称。
我知道检索最后一个项目的修改日期很简单,但是如何检索进行此类修改的用户呢?
检索网络中最后修改的项目也可以,因为我会选择“修改者”字段的值。
解决方案
所以......只是为了确认......您想检查某些网络中所有列表和库中的所有项目,并从每个列表中获取最后修改的项目并获取修改它的用户,对吗?:)
如果是这种情况,这种 PS 脚本应该可以解决问题
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
try
{
$siteUrl="[URL]";
$web = Get-SPWeb $siteUrl;
$spQuery = New-Object Microsoft.SharePoint.SPQuery;
$spQuery.ViewAttributes = "Scope='Recursive'";
$spQuery.Query = ""
$spQuery.RowLimit = 1;
$lastDate = $null;
$lastUser = $null;
foreach($list in $web.Lists)
{
Write-Host 'checking list -' $list.Title;
$items = $list.GetItems($spQuery);
if($items.Count -gt 0)
{
if($lastDate -eq $null)
{
$lastDate = $items[0]['Modified'];
$lastUser = $items[0]['Editor'];
}
else
{
if((get-date $items[0]['Modified']) -gt (get-date $lastDate))
{
$lastDate = $items[0]['Modified'];
$lastUser = $items[0]['Editor'];
}
}
}
}
Write-Host 'last user that modfied some item in this web was - '$lastUser ' - ' $lastDate;
}
catch
{
Write-Host $_.Exception.Message;
}
我希望它有帮助:)。
推荐阅读
- r - 基于唯一配对的子集数据
- java - 运行新的 App Engine 应用程序时,Eclipse IDE 启动了一个新的 App Engine 标准实例
- java - 如何在android中的OpenGL java中编写文本或将图像放在3D立方体的顶部(对象用于增强目的)
- objective-c - AVAudioPlayerNode 获取当前时间不正确
- c - realloc 似乎没有重新分配内存
- node.js - Node & Yarn 命令方式
- c++ - openssl 查询客户端证书
- ruby-on-rails - 模型创建的 Rspec 测试
- node.js - 切换功能?
- swift - Xcode 升级后 Core Data 出现数据丢失