Export information from Active Directory to a CSV file

I wanted to reboot all PC’s in a particular OU of our Active Directory structure.  I found csvde which is a tool for exporting and importing data to and from Active Directory.
Once I got all of the computer names out and into a csv file I used the shutdown -i tool to past the computer names into and let it remotely reboot them.

Here are some sample csvde scripts for exporting various pieces of information:

Export everything (computers, users, groups etc.  This could be a lot of records depending on your Active Directory so be careful.):

CSVDE -f exportFilename.csv

Export computer accounts from specified OU with only a few columns (just does dn, cn and name columns):

csvde -f ComputerNamesExport.csv -d “OU=OUName,DC=domain,DC=org” -r “(objectClass=computer)” -l “dn,cn,name”

– You can leave off the -l “dn,cn,name” and you’ll get all columns.

Export user accounts from whole domain with only the specified columns:

csvde -f \\server1\common\it\UserNamesExport.csv -d “DC=CBCO,DC=org” -r “(objectCategory=person)” -l “dn,cn,displayName,description,title,department,physicalDeliveryOfficeName,company”

– You can leave off -l and the rest to get all columns.

Redirect new computer accounts in Windows Server 2003 domain to a different location

2003server.jpg
While studying for the MCSE 70-294 test on active directory I ran across this little command that I was previously not aware of. redircmp.exe

So, you can type:  redircmp ou=mycomputers,DC=corp,dc=com

Replace the mycomputers with the ou (organizational unit) that you want all new computer accounts to go to.  Replace the corp with your domain name and the com with

Pretty cool!  I made a new OU where I store my computer accounts in and I always forget that new computer accounts go to the computers ou and it generally takes me a minute or two before I remember.  This way new computer accounts will automatically go to the ou of my choice.

Go here to Microsoft’s website for more info on these commands.

You can also use: redirusr ou=myusers,DC=corp,dc=com

This will redirect the location that new user accounts are made in.  I don’t use this one, but it is good to know.