Skip to content

Instantly share code, notes, and snippets.

@BrendanThompson
Created February 7, 2015 06:45
Show Gist options
  • Save BrendanThompson/a222c88e86c9db5c53c8 to your computer and use it in GitHub Desktop.
Save BrendanThompson/a222c88e86c9db5c53c8 to your computer and use it in GitHub Desktop.
Retrieves all AD Groups used for permissions recursively within SharePoint
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteCollection = New-Object Microsoft.SharePoint.SPSite("http://companyweb")
foreach ($site in $siteCollection.AllWebs)
{
foreach ($role in $($site.Roles))
{
foreach ($user in $role.Users)
{
if ($($user.IsDomainGroup) -eq $True)
{
Write-Output $user.LoginName
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment