How To: Get a list of site owners for all SharePoint sites

Here is something you may need to verify your users have the access they require: a PowerShell script which will run through all of the site collections and webs and display the list of site owners (people who belong to a Owner group).

Something like this:

Basically you save the code below as a ps1 script and run it in SharePoint Management Shell.
If the output is too long, pipe it to file by using >> c:\output.txt in the command line calling the script.


function IterateSubSites ([Microsoft.SharePoint.SPWeb]$subSite)
{
if ($subSite -ne $null)
{
if($subSite.Webs -ne $null)
{
foreach($subsites in $subSite.Webs)
{
IterateSubSites($subsites)
}
}
}
}

$webApplicationURL = "http://localhost"
$webApp = Get-SPWebApplication $webApplicationURL

foreach($site in $webApp.Sites)
{
foreach($subWeb in $site.AllWebs)
{
Write-Host $subWeb.Url
foreach($group in $subWeb.Groups)
{
if($group.Name -like "*Owners*")
{
Write-Host "Owner(s): "
foreach($user in $group.Users)
{Write-Host $user.Name "; "; }
}
}
if($subWeb.IsRootWeb -ne $true)
{
IterateSubSites($subWeb)
}
$subWeb.Dispose()
}
$site.Dispose()
}

 

http://www.sharemuch.com/2012/10/16/how-to-get-a-list-of-site-owners-for-all-sharepoint-sites/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+YaroslavPentsarskyysDevelopmentBlog+%28Yaroslav+Pentsarskyy%27s+Development+Blog%29

Advertisements