Powershell – Export users and select attributes from a single OU

Recently needed to find a way to export all staff into a csv file with only their name and EmployeeID.

First I ran the GET-ADuser command below for a single user. This will display all the user’s attributes. Be sure to change username to a domain user.

get-aduser username -Properties *

Now that you have a file with all the attribues fine the attribues names and copy them out.

Get-ADUser -Filter * -Properties * -SearchBase "OU=Staff,OU=_District-Delegated,DC=EXAMPLE,DC=k12,DC=or,DC=us" | Select-Object name, EmployeeID | export-csv -path C:\Temp\staff_employeeID_2020.csv

You’ll now have a csv file with all the user names and Employee ID’s if those are the attributes you selected.

Show More

Cory Fiala

Technology and outdoor enthusiast. Currently the sole systems administrator for a local K-12 school district with 800+ staff and 5,500+ students. I support windows servers, Linux systems (FreeBSD and Ubuntu), along with vSphere (4 node cluster). 60+ virtual machines and 8 physical servers. This doesn't include my personal homelab.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button