Exporting Active Directory Users From A Specific OU

I am trying to find a way to export my Active Directory User accounts from specific OU's rather than just performing an entire export from the whole of Active Directory.

My goal is to be able to export the users and hopefully be able to also stat which fields I would like to export.

If anyone has experience with this that would be great, thanks for your help.
Who is Participating?
Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
Pretty strightforward... Use the below command...

Import-module activedirectory
Get-Aduser -Filter * -Searchbase "OU=testou,DC=mydomain,DC=com" -properties * | select name, samaccountname | export-csv c:\testou_user_export.csv

Open in new window

Make sure that you change the -Searchbase string to the location in your AD environment.

You can also use the "get-aduser | get-member" (without quotes) to see what other properties you want to add to your export.


Powershell is the best way to go ( As I am learning from all in this forum )

You can also use this tool .
carlocAuthor Commented:
Worked nicely, thanks.
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.

All Courses

From novice to tech pro — start learning today.