AD Lookup via EmployeeID > Export user info to csv

I have a CSV/TXT file with the heading of EmployeeID

How can I export a list to csv from AD that contains only the users listed in that EmployeeID file via powershell?


I want the command to find the EmployeeID "3374" (for example) and export the userprincipalname, displayname, samaccount etc...
Christian HansUndecided... Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daryl BamforthTechnical ExpertCommented:
Import into powershell, then cycle through with a foreach.

$EmployeeIDs = import-csv -path 'path to csv'\employeeid.csv
$Users = @()
foreach ($EmployeeID in $EmployeeIDs) {
    $user = get-aduser -filter 'Employeeid -eq "$($employeeid)"' |select SamaccountName, UserPrincipleName, Name
    $users += $user
$users |export-csv -path 'path to export'\userdetails.csv -notypeinformation

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITSysTechSenior Systems AdministratorCommented:
In addition to using a powershell command. I would highly recommend using Active Directory Explorer, it is simple to use and will allow you to create your own search criterias with ease.
Daryl BamforthTechnical ExpertCommented:
Script will do as requested.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.