サイト (Web) スコープ内のすべてのライブラリのすべてのドキュメントを、以下にリストされている CSV ファイルに出力する PowerShell スクリプトがあります。
function Get-DocInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
$web = Get-SPWeb "http://contoso.com/sites/Depts/HTG"
foreach ($list in $web.Lists) {
if ($list.BaseType -eq “DocumentLibrary”) {
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"]
"Modified By" = $item["Editor"]
"Modified Date" = $item["Modified"]
"Item Name" = $item.File.Name
"URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
}
New-Object PSObject -Property $data | Select "List Name", "Item Name", "Version", "Created By", "Created Date", "Modified By", "Modified Date", "URL"
}
}
$web.Dispose();
}
$site.Dispose()
}
}
Get-DocInventory | Export-Csv -NoTypeInformation -Path C:\NewOutput.csv
最後にもう 1 つ、すべてのライブラリからすべてのドキュメントを出力するだけでなく、同じサイトhttp://contoso.com/sites/Deptssのすべてのリストからすべてのアイテムをプルするスクリプトを追加する必要があります。 /HTGは上記のスクリプトに記載されています。誰かがそうする方法を教えてもらえますか? これについて誰かの助けが本当に必要です。
注: すべてのリストを反復処理するには、ドキュメント ライブラリを反復処理する以下の行を変更できます。
if ($list.BaseType -eq “DocumentLibrary”)
リストを反復処理するには、次のようにします。
if ($list.BaseType -eq “GenericList”)
ドキュメント ライブラリとリストの両方をループしたい。どうすればいいですか?