Skip to content Skip to navigation

Translating a list of SUnet IDs to Full names

Posted by: 

Here's the problem. There is a list of SUnet IDs. You need a list of real/full names. The list is very long so you need an automated way.

First step is to generate a list of SUnet IDs.

From a computer that has powershell
import-module activedirectory
get-adgroupmember "ADGroupName" -Recursive | Select-Object name
//This will output a list of SUnet IDs. Remove -Recursive if nested members is not needed.

//Copy the list of SUnet IDs to a text file called user.txt. Change DOMAIN to the Windows domain in which the user accounts are stored.
Get-Content user.txt | foreach {(Get-ADUser $_ -Properties DisplayName -Server DOMAIN).DisplayName }

for i in `cat user.txt`; do echo "getent passwd \"$i\" | awk -F\":\" '{print \$5}' >> uesrFullName.txt"; done