I recently had to move users shares from one server to another and needed to update the location of every user home drive in Active Directory. It wasn’t possible to do this using the MMC snap-in as some shares had slightly different paths (ie, I couldn’t select all the users and put in \\newserver\users\%username%).
A powershell script worked quite well (source):
Import-Module ActiveDirectory $oldServerName = "myoldserver2008" $newServerName = "newserver2015" [array]$AllUsers = Get-ADUser -Filter * -Properties HomeDirectory foreach($user in $AllUsers){ if(($user.HomeDirectory.ToString()).contains($oldServerName)){ $homeDirectory = ($user.HomeDirectory.ToString()) -replace $oldServerName, $newServerName write-host $user.HomeDirectory.ToString() set to $homeDirectory Set-ADUser $user.DistinguishedName -HomeDirectory $homeDirectory } }
If you wanted to test this code without changing the users just remove the “Set-ADUser” (below the write-host line) line from the above script and it will just write out the changes that it would perform to the screen without making the changes.
Ideally you should be using this method to move your user shares to a DFS location so “server name changes” are not required in the future and you can have redundant storage.