//john pfeiffer 24oct07 MCSE command line tools http://www.computerperformance.co.uk/Logon/DSGet.htm http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm http://technet2.microsoft.com/windowsserver/en/library/96a4a5ee-ee72-44d5-845f-71b2de33d4411033.mspx?mfr=true (MS links break very fast...)
CSVDE -f ADoutput.csv //export to csv file the AD csvde -f lastlogontimes.txt -r objectclass=user -l lastlogon -f //csv cannot modify, only create new objects //objectclass user also returns computer objects
csvde -f allpersons.csv -r objectcategory=person //will export users & contacts csvde -f users.csv -r "(&(objectclass=user)(objectcategory=person))" // the " and & are important! csvde -f user-logons.txt -r "(&(objectclass=user)(objectcategory=person))"
csvde -f user-logons.txt -r "(&(objectclass=user)(objectcategory=person))" -l "cn,lastlogon,badpwdcount,logoncount"
//-l (L) allows us to control which columns are displayed
csvde -f emailaddresses.csv -l proxyAddresses //case sensitive!
csvde -i listofgroups.csv //imports from csv (excel?) to AD
LDIFDE -f users.ldf -s DC1.contoso.com -d "ou=UsersOU,dc=contoso,dc=com" -r "(&(objectcategory=person)(objectclass=user))" //exports a file users.ldf with the list of users...
"NewUsers.ldf" dn: CN=afuller, OU=UsersOU, DC=contoso, DC=com changetype: add cn: afuller objectClass: user samAccountName: afuller
dn: CN=rking, OU=UsersOU, DC=contoso, DC=com changetype: modify replace: description description: Marketing Administrative Assistant
ldifde -i -f NewUsers.ldf -s DC1.contoso.com
dn: cn=marketing,ou=cmdline,dc=williamscollege,dc=local changetype: modify replace: mail mail: test2@xyz.com -
ldifde -i -f test.ldf -s williamscollege.local
(note: I used csvde -r objectclass=group -f ADgroups.csv to see the properties available)