Get entire SharePoint farm webs inventory
function Get-DocInventory() {
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$farm =
[Microsoft.SharePoint.Administration.SPFarm]::Local
foreach ($spService
in $farm.Services) {
if
(!($spService -is [Microsoft.SharePoint.Administration.SPWebService])) {
continue;
}
foreach
($webApp in $spService.WebApplications) {
if ($webApp
-is [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]) {
continue }
foreach
($site in $webApp.Sites) {
foreach
($web in $site.AllWebs) {
foreach ($list in $web.Lists) {
$data = @{
"Web Application"
= $webApp.ToString()
"Site" = $site.Url
"Web"
= $web.Url
"list" = $list.Title
"Item
Count" = $list.ItemCount
}
New-Object PSObject -Property $data
}
$web.Dispose();
}
$site.Dispose()
}
}
}
}
#Get-DocInventory | Out-GridView
Get-DocInventory | Export-Csv -NoTypeInformation -Path
c:\SP_Inventory.csv
Comments
Post a Comment