Created
October 13, 2019 13:59
-
-
Save jonchampagne/37d96bfde6e11e62e31399d79c1e5cb2 to your computer and use it in GitHub Desktop.
Recursively get all groups an active directory user or group is a part of
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ADMembershipRecursive($name){ | |
$names = [System.Collections.ArrayList]@() | |
Get-ADPrincipalGroupMembership -Identity $name | ForEach-Object { | |
$names.Add($_.Name) | Out-Null | |
Get-MembershipRecursive -name $_ | ForEach-Object { | |
$names.Add($_) | Out-Null | |
} | |
} | |
return $names | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment