Powershell script to search for and list or sites in a site collection

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) > $null

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
$webapps = @()

foreach ($websvc in $websvcs) {
write-host “Web Applications”
write-host “”
foreach ($webapp in $websvc.WebApplications) {
write-host “Webapp Name –>”$webapp.Name
write-host “”
write-host “Site Collections”
write-host “”
foreach ($site in $webapp.Sites) {
write-host “Site URL –> –>” $site.URL
write-host “”
write-host “Websites”
write-host “”
foreach ($web in $site.AllWebs) {
write-host “Web URL –> –> –>” $web.URL
write-host “”
write-host “Lists”
write-host “”
foreach ($list in $web.Lists) {
write-host “List Title –> –> –> –>” $list.Title
write-host “”
}

foreach ($group in $web.Groups) {
write-host “Group Name –> –> –> –>” $group.Name
write-host “”

foreach ($user in $group.Users) {
write-host “User Name –> –> –> –>” $user.Name
write-host “”
}
}

}

}

}
}

 

Advertisements

SharePoint 2007 View All Site Content Showing the wrong number of items

I noticed recently the number of items in a page library seems to be wrongly reported sometimes. For example, when I click on view all site content, number of pages shown in the publishing library is 20.

If I open the library to count the pages there’s 14 visible. I don’t know whether this applies to documents or not as I don’t fancy counting¬†hundreds of them!

Does anybody know why this is?¬†… or what the solution may be?