Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We're migrating our user folders to a new server. They're of the form \\server\users\UserName\, so \\server\users\Tim Smith\. We essentially want to change server to server1 We have quite a few users; so manually editing each user is time consuming.

Any suggestions as for tools I can use to batch edit all my users?

share|improve this question

4 Answers 4

up vote 7 down vote accepted

Active Directory Users and Computers can do what you want, if your user folder names match their account names.

Assuming all the users are in the same OU, just highlight all of them, right-click and choose "Properties", got to the "Profile" tab, and enter the new path in the form:

\\server\users\%USERNAME%\

If they're spread out over multiple OUs it's a little tougher, but not much. Assuming you're using the Windows 2003 version of Active Directory Users and Computers:

  • At the "Saved Queries" node at the top of AD, do a "New" / "Query".

  • Name the query whatever you'd like and supply a description if you'd like. In the query definition, choose an OU above the user accounts for the "Query root" (or the root of the domain, if they're in OUs that are children of the root).

  • Click "Define Query". In the "Find Common Queries" dialog, choose "Has a value" from the drop-down list to the right of the "Name" caption on the "Users" tab. Click "OK" and "OK" again to define the query.

  • Highlight your newly-created query and right-click and choose "Refresh" (or press F5) if the query isn't populating the right pane.

  • Highlight users in the right-pane, right-click and choose "Properties". Go to the "Profile" tab and make the change as described above.

Easy as pie.

share|improve this answer

Alternately, you could use a batch file to manage this and run it as a script, if you do not want to use the GUI. Or you could just type it into a command line.

I would run it something like this, if you want to alter all the users across your domain.

dsquery users | dsmod user -hmdir \\server\users\$username$\

dsmod recognizes that the $username$ flag means the samid of the user that is piped to it from the dsquery command. It also recognizes this flag for the -profile command attached to the dsmod command.

Note: If your shared folder is a hidden share this will not work, the question mark in the hidden share fools the command into thinking you are starting the flag earlier then you really are. I have experimented with some escape characters for this but have not found any so far that resolves this issue.

If all your users are in a specific OU you need to change the dsquery command. For that command you need to add the fully qualified domain name of the OU that contains all the users you want to change. This can be found, funny enough, through the dsquery OU command.

The command would then look like this,

dsquery users [fully qualified domain name of the OU ] | dsmod user -hmdir \\server\users\$username$\

If you want to batch this and use a hidden share you can use a FOR loop to do so, but the syntax gets a bit convoluted because of the loops required to first extract all the users, then extract just their names, and then go back and plug that info into specific areas of a dsmod command. It's ugly, but I would do it something like this.

dsquery user [fully qualified domain name of the ou] > c:\users.txt & for /f "delims==, tokens=2" %A in (c:\users.txt) do (dsmod user "CN=%A[rest of FQDN here] -hmdir "\\server\users$\%A\" && del c:\users.txt -q

Note: If you use this in a batch file, the for loop token must be preceeded by double percentages, ie; %%A instead of %A

This queries all the users in the OU specified then outputs them to a file. It then runs a for loop, plucking the user's name out of the FQDNin the file and plugging it into a dsmod command that changes their home directory. Finally it cleans itself up by deleting the file it created if the for loop ran successfully.

I hope this helps, even if you don't use a batch file to do this particular job it can help you in the future. The nice thing about something like this is that you can save it and if you need to change something else in the future just a couple little changes and all you have to do is rerun it to make the changes you want. In addition if you find someone made unauthorized changes you can switch it back just with a double click.

share|improve this answer

You can use ADModify.NET to bulk change user attributes.

http://www.codeplex.com/admodify

share|improve this answer

The other Scripting-based answers are all fine (and scripting is my best hammer), but you could also accomplish the same with a DNS CNAME and a server rename. Change 'server' to 'oldserver', and CNAME 'server'->'server1'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.