How to count number of pages in Site and Sub Sites using powershell ??
Thanks
You can use the script below :
$URL="http://site.Site.com"
$BASETEMPLATE="Pages"
$site = Get-SPSite $URL
$totalItems = 0
foreach($web in $site.AllWebs)
{
$lists = $web.Lists
for ($i=0; $i -le $lists.Count – 1; $i++)
{
$list = $lists[$i]
if ($list.Title -eq "Pages")
{
$totalItems = $totalItems + $list.Items.Count
}
}
}
$site.Dispose()
write-host $totalItems
$sitecollURL = " "
$totalsubsites = 0
$site = Get-SPSite $sitecollURL
foreach($subsites in $site.AllWebs)
{
$totalsubsites++;
}
write-host $totalsubsites