• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 119
  • Last Modified:

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?

Example:
EmployeeID
3374
3550
3401

I want the command to find the EmployeeID "3374" (for example) and export the userprincipalname, displayname, samaccount etc...
0
Christian Hans
Asked:
Christian Hans
  • 2
1 Solution
 
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

1
 
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.
0
 
Daryl BamforthTechnical ExpertCommented:
Script will do as requested.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now