Display SharePoint Site collection Administrators

This script displays all Site collection Administrators along with their email addresses for all web applications.

Get-SPSite | % {$_.RootWeb.SiteAdministrators} | select @{name='Url';expr={$_.ParentWeb.Url}}, LoginName, Email

If you are on WSS v.3/MOSS 2007 use the next defenition for Get-SPSite

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null
function Get-SPSite{
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$farm.services | % {if($_.WebApplications.Count){$_.WebApplications}} | % {if($_.sites.Count){$_.sites}}
}

Advertisements