Export active directory users to CSV

For many reasons, we sometimes need to Export active directory users to CSV.
We can perform this operation in some ways, the two best ways are the Dsquery command and the PowerShell cmdlet Get-ADUser.

To use DSquery command to export users to CSV, we should use samAccountName and Name while Modifying the filter based on information needed as follow:
Dsquery * -filter “&(objectClass=User)(objectCategory=Person)” –attr samAccountName Name >>MyUsers.csv

To use Get-ADUser command:
Get-ADUser -Filter * -SearchBase “ou=OU,dc=Gmalaya,dc=Local” -Properties * | Export-Csv  “d:\MyUsers.csv”

Alon Yardeni

Information Technology specialist in Windows products: windows OS, Office, windows servers, Symantec Product, networking.
Media & Video specialist with Adobe products.
Founded Gmalaya at 2008.

Latest posts by Alon Yardeni (see all)