So I had a need to get a csv that could tell me who was in which groups in which sites.
Powershell to the rescue! This is what I ended up with …
There may be a better way to do this but the main thing is that it works and it was quick!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
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 } } } } } } |