How to bulk update fields in Active Directory

The quickest and easiest way I’ve found to update user account info in Active Directory on Windows 2003 is to use the ‘dsmod’ command on the GC server. I’ve listed a couple of example commands below, but you can also get additional information by typing ‘dsmod /?’, or ‘dsmod user /?’ on the command line on your Active Directory server.

The following command will update the Department field on a user object in Active Directory.  Content between { } requires data specific to your environment.

dsquery user -samid {uid} “{cn=sers,dc=domain,dc=local}” | dsmod user -dept “{dept name}” -u {adminuid} -p {adminpwd}

The following command will update the telephoneNumber field on a user object in Active Directory.  Content between { } requires data specific to your environment.

dsquery user -samid {uid} “{cn=users,dc=domain,dc=local}” | dsmod user -tel “{extension}” -u {adminuid} -p {adminpwd}

To apply changes to multiple users at a time, create a text file with the appropriate information for each user account.  Save the text file with the .cmd extension and execute in on your Active Directory server.  The easiest way to create the file is to export a list of user from Active Directory to a .csv file.  Import that list into Microsot Excel and insert columns with the additional command information from the sample command above for each user.  Save the file back out as a .csv file.  Rename the file as a text file, clean it up, change the file extension to .cmd and run it on your AD server.

The same procedures can be performed against a Windows 2000 server/domain by executing the dsquery/dsmod commands from a Vista workstation that’s a member of the Windows 2000 domain.