Skip to content

Instantly share code, notes, and snippets.

@atrommer
Created February 20, 2014 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atrommer/9125798 to your computer and use it in GitHub Desktop.
Save atrommer/9125798 to your computer and use it in GitHub Desktop.
Get Count of all pages in all site collections in all webapps
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