Find user accounts in nested groups

Does anyone else have this problem, or is it just me? I get stumped from time to time:

Somewhere there is a distribution group which in turn contains other distribution groups as members, as can be seen here in the example:

Nested group

In practice, there are usually distribution lists, such as "Finance", then "Finance - Europe", "Finance - America" or "Finance - Asia". Within the sub-distributor, you will then find further distributors until the whole thing becomes slightly opaque:

Nested group

At some point, after umpteen nested groups, the user account appears:

User account

At some point it starts: Why does the user have write access to the folder XYZ or why does the user receive mails from the purchasing distribution list etc. etc.

This happens to me quite often, so I made a little PowerShell script for it.

The script works very simply:

The group in which a user is to be searched for is entered in the first 1 line. The user account to be searched for is entered in line 2:

Script

When the script is executed, it now displays the group chain, which extends from the distribution group (or security group) down to the user object:

Find user accounts in nested groups

The script requires the ActiveDirectory module for the PowerShell. Maybe someone can use it. The script can be downloaded here:

Leave a Comment