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.