i need to find users from a specific OU that belong to a set of nested groups (that part is done), and write which of the groups the users belong to (user can belong to several groups) right now i have all the users that belong to the groups, but cannot figure out how to also list all the groups from the nested set they belong to.
my script so far:
$GroupDN = (Get-ADGroup "Groupname").DistinguishedName
$Users = Get-ADUser -LDAPFilter "(&(memberOf:1.2.840.113556.1.4.1941:=$GroupDN))" -SearchBase $OU | select name | Export-Csv C:\test\data.xml ```
Continuing from my comment, and per the link provided:
hit(s) --- of course, tweak as needed to get to your final results
As well as this on via SO Q&A regarding the similar use case:
... or this example for the same search, using the code you already posted as a function which you just pass an identity.
As well as graphical views
See also: