One-liner to get all the members of an AD group

With this line you get all the users of an Active Directory group recursively, so any nested group is expanded. It is also exported to a CSV file.

Get-ADGroupMember -Identity 'GroupName' -Recursive |
Get-ADUser -Properties '*' |
Select-Object samAccountName, name, givenName, sn, mail, l |
Export-Csv -Encoding UTF8 -Delimiter ';' -path '.users.csv'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s