karlpearson
asked on
Get real name from ad account logon name
Hi,
Hope someone can help me please. I am looking for a powershell script that will take a txt file containg AD usernames and output next to the usernames the real names from the AD accounts of the user's in question. e.g.
Username Real name
usera John Smith
userb Davey Jones
Is this possible in powershell? or does this need to be done in vbs.
Hope someone can help out.
Regards,
Karl.
Hope someone can help me please. I am looking for a powershell script that will take a txt file containg AD usernames and output next to the usernames the real names from the AD accounts of the user's in question. e.g.
Username Real name
usera John Smith
userb Davey Jones
Is this possible in powershell? or does this need to be done in vbs.
Hope someone can help out.
Regards,
Karl.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This solution uses Quest's AD snapin and outputs the result into Users2.TXT file. Customize the paths in lines 1 and 6.
$users = Get-Content c:\ee\users.txt
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction silentlycontinue
$users | ForEach-Object {
Get-QADUser -SamAccountName $_ | Select-Object @{n="Username";e={$_.samaccountname}}, @{n="Real name"; e={$_.displayname}}
} | convertto-Csv -NoTypeInformation -Delimiter "`t" | %{$_ -replace '"',""} | Set-Content -Path C:\ee\users2.txt -Encoding unicode
ASKER
Great stuff thank you
http://technet.microsoft.com/en-us/library/ff730940.aspx