I have to list full subgroup dependency of specific group - filter -> only subgroups which contain at least 1 user.
I have tried this approach:
dsquery group -samid <specific_group> | dsget group -members -expand | dsquery * -filter "(&(objectclass=group))"
This is an adapted version of my answer here to omit groups without any user object.
Unfortunately, using
Get-ADGroupMembertogether with switch-Recursivewill not return members that are groups.As the docs state:
To get an array of nested group objects within a certain parent group, you will need a recursive function like below: