November 24, 2011

PowerShell Script To Display All SharePoint Site Collection Administrators In Web Application


In my SharePoint Environment, we got a requirement to populate site collection admins list from the couple of  web applications. each web appilication contains 30+ sitecollections. so to pick the list in a manual way is a bit difficult & i am lazy too. so i got this below script in the artcle, and i modified according to my requirement to generate a report. script as below:

$siteUrl = Read-Host "Enter Site URL"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication
 foreach($site in $spWebApp.Sites)
    Write-Host "-----------------------------------------------------------"
    Write-Host "$site"
    foreach($siteAdmin in $site.RootWeb.SiteAdministrators)
        Write-Host "$($siteAdmin.Name)"
    Write-Host "-----------------------------------------------------------"


No comments:

Post a Comment