Forum Discussion
Scouter_Ted
Dec 31, 2019Copper Contributor
Searching multiple AD security groups for members?
I'm not sure if this is off topic for this group, but the groups control the licensing for O365 for exchange hybrid, so I figured this would be a good place to start. Every time a user leaves the...
VasilMichev
Jan 02, 2020MVP
Depends on the group type. Generally speaking, you can use the good old AD tools:
/// List all groups (non-recursive)
(Get-ADUser -Filter {UserPrincipalName -like "XXXXXXXX"} -Properties MemberOf).MemberOf
/// List all groups (recursive)
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=CN=XXXXXX,OU=User,OU=Accounts,OU=P01,DC=domain,DC=com)" | measure
where I've used the LDAP_MATCHING_RULE_IN_CHAIN identifier ("1.2.840.113556.1.4.1941"): https://docs.microsoft.com/en-us/windows/win32/adsi/search-filter-syntax?redirectedfrom=MSDN