Many times we want to export information from Active Directory, to such an excel. To this end a very useful tool is the command CSVDE:

to see how it works it’s best to give some examples:

CSVDE -f usuarios.csv

Exports the object type ‘user’ and ‘computer’ Active Directory to a csv file

CSVDE -d “OU=Ejemplo,dc=es” r objectCategory=person -f usuarios.csv

Exports only objects domain user type

CSVDE -f usuarios.csv -r “(&(objectClass=user)(sn=Pe*))”

Export users only objects where the name starts with “Pe” the “&” indicates a start logical “AND”

CSVDE -f usuarios.csv -r” (|(useraccountcontrol=20)(useraccountcontrol=30)(useraccountcontrol=333))”

Exports only objects where the userAccountControl field is equal to 20 or 30 or 333, the operator “|” indicates the logical initial “O”

CSVDE -f usuarios.csv  -l “DN, objectclass, objectcategory, givenName, sn”

Exports only the selected columns to see all selectable attributes of an object such person, a very useful page is:

Microsoft ldap person reference