Powershell – Get members of AD Group

Sometimes you will need a fast and easy way to list who is a member of a AD group.  Start Powershell and enter either of the following commands:

Get-ADGroupMember -Identity "TestGroup" | Select samAccountName,Name,@{Name="DisplayName";Expression={(Get-ADUser $_.distinguishedName -Properties displayname).Displayname}},@{Name="Title";Expression={(Get-ADUser $_.distinguishedName -Properties Title).title}}
Get-ADGroupMember -Identity "TestGroup" | Select samAccountName,Name
Get-ADGroupMember -Identity "TestGroup" | Select samAccountName

Sometimes you will want the output to a textfile, add > textfile.txt

Get-ADGroupMember -Identity "TestGroup" | Select samAccountName,Name  > textfile.txt