Display SharePoint 2007/2010 Site Collection Administrators

This script displays all SharePoint site collection administrators within a given web application. User is prompted for site url if none is given.

 
 
 
 
 
3.8 Star
(10)
Add to favorites
SharePoint
3/25/2011
E-mail Twitter del.icio.us Digg Facebook
  • No output on wss 3.0
    2 Posts | Last post August 31, 2012
    • Hello - when I try to run this scrip on a wss 3.0 farm, it just outputs dashes for each site collection - that's it.  Like this:
      -
      -
      -
      -
      -
      
      Also, how would I be able to pipe this to an excel file?
      
      Thanks,
      
      
    • Just add few lines as I have mentioned below. All the O\p will be in a excel
      
      $siteUrl = Read-Host "Enter Site URL"
      $rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
      $spWebApp = $rootSite.WebApplication
      foreach($site in $spWebApp.Sites)
      {    
      foreach($siteAdmin in $site.RootWeb.SiteAdministrators)  
      {        
      $a = "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.DisplayName)" 
      
      $a | Out-File E:\RESULT_new.xls
        }    
      $site.Dispose()
      }
      $rootSite.Dispose()