Created
February 20, 2014 23:44
-
-
Save atrommer/9125798 to your computer and use it in GitHub Desktop.
Get Count of all pages in all site collections in all webapps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | |
$report = "$PWD\pagesBySC.txt" | |
$webapps = Get-SPWebApplication | |
$pgTotal = 0 | |
foreach ($wa in $webapps) | |
{ | |
$pgWA = 0 | |
$sites = $wa | select -Expand Sites | |
foreach ($site in $sites) | |
{ | |
$pgCount = 0 | |
foreach ($web in $site.AllWebs) | |
{ | |
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) { | |
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) | |
$pages = $pWeb.PagesList | |
$pgCount += $pages.ItemCount | |
} | |
} | |
Add-Content -Path $report -Value "$Site $pgCount" | |
$pgTotal += $pgCount | |
$pgWA += $pgCount | |
} | |
Add-Content -Path $report -Value "Total for $wa : $pgWA" | |
} | |
Add-Content -Path $report -Value "Total Pages: $pgTotal" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment