我有一个脚本,可以将所有列表和库中的所有项目/文件输出到 CSV。此外,它还显示项目/文件的当前和以前版本。这还显示了哪个用户修改了每个版本的文件,还显示了每个版本修改文件的日期/时间:
function Get-DocInventory([string]$siteUrl) {
$web = Get-SPWeb "http://contoso.com/sites/Depts3/HBG"
foreach ($list in $web.Lists) {
foreach ($item in $list.Items) {
foreach($version in $item.Versions){
$data = @{
"Version" = $version.VersionLabel
"List Name" = $list.Title
"Created By" = $item["Author"]
"Created Date" = ($item["Created"] -as [datetime]).DateTime
"Modified By" = $version["Editor"]
"Modified Date" = ($version["Modified"] -as [datetime]).DateTime
"Item Name" = $item.Name
}
New-Object PSObject -Property $data | Select "List Name", "Item Name", "Version", "Created By", "Created Date", "Modified By", "Modified Date"
}
}
$web.Dispose();
}
}
Get-DocInventory | Export-Csv -NoTypeInformation -Path C:\GenerateReport.csv
以下是脚本输出的示例:
下面是我在访问 Lions.pdf 文件的版本历史时看到的一个 excel 示例:
我有两个问题:
- 修改者列显示不需要的电子邮件和域用户名。
- 我的脚本将“修改日期”列显示为提前 5 小时。Lions.pdf 版本 1 的脚本输出显示时间为上午 11:23。但是当我转到 Lions.pdf 的版本历史时,它说版本 1 在上午 6:23 被修改。时间差异与提前 5 小时相同,这是不正确的。
我似乎无法弄清楚我在这里做错了什么。有人可以帮助解决我遇到的问题吗?我主要关心的是时间,我将不胜感激任何帮助。