Powershell, get full names of a group of users in AD and export to text file.

Just a quick blurb that I encountered this morning.
In powershell, to get a list of the full names of users and export them to a text file:

Get-ADGroupMember -identity GROUP -Recursive | Get-ADUser -Property DisplayName | Select Name > c:\temp\fullnamesofgroup.txt

The point is that Get-ADGroupmember doesn’t “have” the properties of the object you are looking at. You have to look into the user object with Get-ADUser to get the specific property of the user object.
So, with the above command, you send all the user objects in the group with Get-ADGroupMember to Get-ADUser, and then pipe the values of the property “Name” to a text file on disk.

(The command is shorter than the text to explain it 🙂 )

Hope this helps you. Have fun!

This entry was posted in Active Directory, powershell. Bookmark the permalink.