Add-PSSnapin Microsoft.SharePoint.PowerShell
function OutputRow($url, $group, $member)
{
$out = new-object psobject
$out | add-member noteproperty url $url
$out | add-member noteproperty group $group
$out | add-member noteproperty member $member
write-output $out
}
foreach ($app in Get-SPWebApplication)
{
foreach ($site in $app.Sites)
{
OutputRow $site.Url "primary site owner" $site.owner
OutputRow $site.Url "secondary site owner" $site.SecondaryContact
foreach($web in $site.AllWebs)
{
if (!$web.HasUniqueRoleDefinitions)
{
OutputRow $web.Url "Everything Inherited from parent" ""
}
else
{
if ($web.RequestAccessEnabled)
{
OutputRow $web.Url "request access email" $web.RequestAccessEmail
}
foreach($group in $web.sitegroups)
{
if ($group.users.Count -eq 0)
{
OutputRow $web.Url $group.name "Empty Group"
}
foreach ($user in $group.users)
{
OutputRow $web.Url $group.name $user.name
}
}
}
}
}
}