Skip to content

Instantly share code, notes, and snippets.

@thesubtlety
Created January 23, 2019 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thesubtlety/263501fc5968909f39f8bab1014bc5a5 to your computer and use it in GitHub Desktop.
Save thesubtlety/263501fc5968909f39f8bab1014bc5a5 to your computer and use it in GitHub Desktop.
Get all AD group membership recursively (requires AD module)
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