Windows Server 2012 R2: Export AD Users to .CSV file

I`ll quickly show how to export AD Users to .CSV file. It can be useful in many situations, and while working with Powershell. I`ll demonstrate simple method, you can add switches, options that you need in your particular case.

Active Directory Users and Computers | Expand your domain | choose OU from which you plan to export |right click – choose Properties | choose Attribute Editor tab | find distinguishedName line and write down the path, you`ll need it for your command.

AD_Export_CSV_1

Next, open Powershell and type in following command (ou*, dc=, dc= values replace with distinguished name you found in your AD in step before):
What is the meaning of command? ” -Filter” is used to specify the query string, “-SearchBase” to specify an Active Directory path to search under and the “-Properties” to specify user’s properties you want to export (* will export all settings assigned to user).
You can read in more details here https://technet.microsoft.com/en-us/library/ee617241.aspx
Specify what you want to export, simple command will look like this:

Get-ADUser -Filter * -SearchBase "ou=!Korisnici,dc=test,dc=local" -Properties * | Export-Csv "c:\ADUsers.csv"

AD_Export_CSV_2

If everything went fine you should see now ADUsers.csv file in root of your C: disk (or in the place you specified)

AD_Export_CSV_3

Now you can use that file with commands in Powershell or whatever purpose you need it for.

 

Disclaimer