View Active Directory Group Members in PowerShell

In this tutorial, I will explain how to display the members of an Active Directory group in PowerShell.

I already see some reaction of the style, we can have it from the graphical interface, it’s true, but in some cases the use of PowerShell saves a lot of time, especially when using ADGLP

I will start from a concert example in order to prove or show you the usefulness of PowerShell.

We will use the Cmdlet:

Get-AdGroupMember

If we take a group, which only contains users, it is quite easy to have the list as shown in the screenshot below:

In PowerShell to get this list you have to use:

Get-AdGroupMember -identity "GG_Aquaman"

We will improve the output by selecting only the name of the users:

Get-AdGroupMember -identity "GG_Aquaman" | select name

Now we will see a case, where the use of PowerShell makes sense.

In my Active Directory, I have a group GG_Super_heros 1 and I want to know the member users.

If we look at the detail of the group, we see that only groups are members.

We could go and see the “sub-groups”, in the other groups there are still groups… so it will become very tedious… and “a good computer scientist is lazy…”

To get the member users, just use the Get-AdGroupMember PowerShell cmdlet with the -Recursive parameter. Which gives us :

Get-AdGroupMember -identity "GG_Super_heros" -Recursive | select name

You know how to get user members of a group recursively.

Small bonus, if you need to have this list in a spreadsheet, it is possible to make a csv output.

Get-AdGroupMember -identity "GG_Super_heros" -Recursive | select name | Export-Csv -path C:\Exports\gg_super_heros.csv -NoTypeInformation

The command does not return anything in this case, it only creates the file.




Leave a Comment