I recently needed to move several hundred users from one server to another—a daunting task. The Microsoft Management Console (MMC) Active Directory Users and Computers snap-in's Profile tab mapped the users' home folder.

Because all the user directories were in the same folder on the server and the To: path is case sensitive when you map to a directory below the share level (e.g., \\server\share\somedir), I was able to write a simple script to change the home folder's Connect To: attribute. This script, which Listing 3 shows, runs from the directory on the server or from a drive mapped to the appropriate location and requires modifyusers.vbs, which is available from the Microsoft Windows 2000 Professional Resource Kit or Microsoft Windows 2000 Server Resource Kit.

The Dir /ad/b command in the For loop iterates the current working directory (dir) and collects only directories (/ad), in a bare format (/b). I use double quotes around %%i and the Universal Naming Convention (UNC) path because the user IDs contain a space. If the UNC or user ID doesn't contain spaces, the double quotes aren't necessary. The %%i code signifies the name of the current directory, which matches the user ID. (The double percent signs—%%—are necessary because the script is a .cmd file; if you typed the code at a command prompt, you could use just one percent sign.) Output from the .vbs script redirects to the modlog.log file. The double ampersands (&&) in the last line cause the final Echo statement to run if the .vbs script line is successful. Thus, you can watch the script's progress.