Exporting AD group members’ display name

Five years ago, I showed you how to export a list of members of an Active Directory group, using a command line query. One issue I’ve run into using this query, is that I get their user name, not their actual name, which tends to make the resulting list hard to parse. As I had a need to export a relatively large number of group members names as part of a recent ticket, I needed a solution that gave me what I wanted straight out of the box.

While you might be able to achieve what you want with a command line query, PowerShell has come to stay, and gives a lot more options, so that’s the format I opted for. The query is built from three sections. First, you need to get the members of the group, then you need to extract their display name, and finally, you need to filter out everything but the displayname. The three sections look something like this:

  • Get-ADGroupMember -identity “GROUPNAME”
  • Get-ADUser -property Displayname
  • select Displayname

I then added the option to export it as a .txt format list, piping each command into the next. As a result, my final command looked like this:

Get-ADGroupMember -identity "GROUPNAME" | GetADUser -property Displayname | select Displayname > filename.txt

Posted

in

, ,

by

Comments

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

This site uses Akismet to reduce spam. Learn how your comment data is processed.