I have a powershell script that list all webs, sites and subsites on a 2007 farm.

I now know how to get last modified date of those subsites...

[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 


Also, any way to get a object count by subsite and site?

And, finally way to report counts (in powershell or sql) on the folowing:

  • objects that are web pages (aspx)

  • objects with code blocks

  • objects with excel services webparts

  • objects that appear to be infopath forms

  • objects with any particular string


  • anybody? Any way to count how many objects have a particular string?
    – Hell.Bent
    Jan 24, 2013 at 12:29
  • An out of box Sharepoint installation with a couple site collections with a few webs each would have hundreds and hundreds of objects. Your question also asks how many web pages contain a particular string. Master pages will put a particular string on every web page, page layouts and web parts could put a string on a large portion. Would you count that as one object or a hundred obects? Also how do you want to count customized content that is pulling from the content and not from the feature. Please ask for something specific so the answer we offer will be helpful to you and those who follow.
    – ghangas
    Feb 6, 2013 at 16:54

1 Answer 1


I've just seen this and whilst I can't provide a complete solution, I might be able to help with the first element. I've used the following scipt to investigate files by thier file extension. It should help you locate any aspx pages. I've not trid to amend it for a web application basis yet but it should serve as a good starting point.

$siteURL = "http://<<YourSiteCollectionHere>>"  
$site = Get-SPSite($siteURL)  
foreach($web in $site.AllWebs)  
    $listCounter = $web.Lists.Count  
    for($i=0;$i -le $listCounter;$i++)  
        $list = $web.Lists[$i]  
        if($list.BaseType -eq "DocumentLibrary") {  
        $newList = $web.Lists.item($list.ID); 
        Write-Host $newList 
        Write-Host "*********************" 
        foreach($item in $list.Items) 
            Write-Host $item.Name 

    Write-Host "-----------------------" 
Write-Host $count

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.