Created
January 23, 2019 17:14
-
-
Save thesubtlety/263501fc5968909f39f8bab1014bc5a5 to your computer and use it in GitHub Desktop.
Get all AD group membership recursively (requires AD module)
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-GroupsRec { | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory)] | |
[string]$User | |
) | |
$dn = (Get-ADUser $User).DistinguishedName | |
Get-ADGroup -LDAPFilter ("(member:1.2.840.113556.1.4.1941:={0})" -f $dn) | select -expand Name | sort Name | |
} | |
#https://stackoverflow.com/questions/23552094/how-to-get-all-ad-user-groups-recursively-with-powershell-or-other-tools |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment