List of SharePoint sites with list of users in %owner% Groups

April 28, 2017 1 min to read
Share

[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)
{
foreach ($webapp in $websvc.WebApplications)
{
foreach ($site in $webapp.Sites)
{
write-host $site.URL
foreach ($web in $site.AllWebs)
{
write-host $web.URL
foreach ($group in $web.Groups)
{
$G = $group.Name
if ($G -match “owner”)
{
write-host ”  –>” $G
foreach ($user in $group.Users)
{
write-host ”     –>” $user.Name
write-host “”
}
}
}
}
}

}
}
GO

Discover more from SamTech 365

Subscribe now to keep reading and get access to the full archive.

Continue reading