Nik's Technology Blog

Travels through programming, networks, and computers

Active Directory Exports using CSVDE

CSVDE - Comma Separated Value Data Exchange

If you need to export all or part of Active Directory a handy Windows utility exists called CSVDE.exe which is located in the System32 directory of Windows 2000 servers.

CSVDE exports to a .CSV file which you can then manipulate in Excel or import into SQL Server.

CSVDE is run from the command prompt and has various switches to enable you to obtain the information you require.

The simplest export, which would export the whole Active Directory would be:

CSVDE -f activedirectory.csv

This would export a file called activedirectory.csv to the directory where CSVDE was run from and would contain all the fields, and there are a lot!

To specify certain fields like the NT logon and email address for example you would use the -l switch:

CSVDE -f activedirectory.csv -l "mailNickname,mail"

CSVDE uses the current users account to log into Active Directory by default, to use another account use the -b switch and specify username, domain and password.

CSVDE -f activedirectory.csv -b username domain password

CSVDE also allows you to create an LDAP search filter, so you can choose to only export only users who match certain criteria. Use the -r switch. The following only exports your details based on a surname match:

CSVDE -f activedirectory.csv -r "(&(objectClass=user)(sn=yoursurname))"

If you have more than one domain controller you can use the -s switch to select the correct one.

Active Directory imports can also be performed using CSVDE by using the -i switch, which sets the mode to import otherwise export is the default mode.