Changing Company Wide AD mapped Home Drives

This is a quick and easy way to change all of your users mapped home drives without manually editing every user. This is really helpful if your migrating to a new file server.

dsquery user “OU=XYZStaff,OU=XYZOU2,OU=XYZOU1,dc=XYZCorp,dc=local” | dsmod user -hmdrv Z -hmdir \XYZ-FileServerStaff$USERNAME$

Simply, the dsquery grabs all of the user accounts in the XYZStaff OU then pipes the results to the dsmod. The dsmod uses the -hmdrv to apply the mapped drive letter and the -hmdir sets the file server location for the users home drive. Remember, the %username% parameter won’t work in this batch – you need to use the $username$ instead.

Of course you can fine tune your user group by adding parameters to the dsquery user command to ensure you only affect the required user objects.


Matt Shadbolt