Link to home
Start Free TrialLog in
Avatar of rov17
rov17

asked on

Script to convert users display name to sam id

Hi everyone,

I need a power shell, vbs script to check an excel sheet or even a csv file that has a display name for some users and convert them to SAMID and output the results in a text file.

Thanks
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


If you were to go with PowerShell, and had Quest's CmdLets there's not much more to it than this:


Import-CSV "YourCSVFile.csv" | `
  %{ Get-QADUser $_.Name } | `
  Select Name, sAMAccountName | `
  Export-CSV "SomeNewFile.csv"


That assumes the CSV file has a column called Name. If it encounters a duplicate name in AD it will output all matches.

Chris
Avatar of rov17
rov17

ASKER

Hi Chris,

Thank for the script, actually the csv file as First name , last name.
Is there is away to get the script checks both First name and the last name ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial