?
Solved

Domain Migration Automation

Posted on 2009-02-15
14
Medium Priority
?
685 Views
Last Modified: 2012-05-06
Hi,
i'm working right now on migrating one domain to another.
The major issue and my assist from you is the workstation migration.
I need to make as close to an automatic process to migrate an old windows profile to the new windows profile.


the major task is to rename the old username under document's and settings to the new username in the new domain (the usernames are not the same) so that for the users nothing would change.

is there a script or a tool that can do so?

if it's a script it would require to search for the last and first name of the user in both domains, find out their username in each domain and rename the folder under documents and settings of the old user's domain to the new one according to the script's search results.

any ideas?
0
Comment
Question by:johnnyjonathan
  • 8
  • 6
14 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 23646654
Hi, this is not a very easy task, and I'm not sure it could be fully automated....here's some information on user migration:

Planning for User Profile Migration
http://technet.microsoft.com/en-us/library/cc728271.aspx

Description of the User State Migration Tool for Windows XP Professional
http://support.microsoft.com/kb/321197/en-us

Moveuser.exe is incompatible with Windows Vista and is replaced by the new Win32_UserProfile WMI functionality
http://support.microsoft.com/kb/930955


Regards,

Rob.
0
 

Author Comment

by:johnnyjonathan
ID: 23653223
RobSamson,
Appriciate your help and fine answers.
quick question if i may:

1. The Movieuser.exe link provides the attached code, can you please explain exactly what it does? i couldn't understand from the link.

strComputer ="."
 
Set objAccount = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
                            & strComputer &"\root\cimv2:Win32_UserAccount." _
                            &"Domain='contoso',Name='fabrikam'")    
 
Set objUserProfile = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" _
                               & strComputer &"\root\cimv2:Win32_UserProfile." _
                               &"SID='" & objAccount.SID &"'")
 
objUserProfile.Delete_

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23654382
Hi there.  The code there is for Windows Vista only.  The Set objAccount part retrieves a user account from the "centoso" domain, that has the account name of "fabrikam"

The Set objUserProfile part then uses the SID of the account that was just retrieved, to be able to obtain a handle on the account's user profile.  A profile cannot be obtained from the username alone, to that's why the two parts work together.

Then, once the correct user profile has been obtained, it is deleted.

Regards,

Rob.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:johnnyjonathan
ID: 23655237
OK, thanks for the explenation.
i'm trying to understand better how User State Migration Tool, according to the artical it does:
1. Identify which application settings to migrate.
2. Identify which file types, folders, or specific files to migrate.
3.Locate these settings and files and create a Migration Rule INF file for them.
4. Run ScanState.exe, copying the user state data to an intermediate store. You can send a shortcut to the script to the users and 5. instruct them to run it when they leave for the evening, or you can deploy the script automatically or on a schedule.
6. Reformat the disk and install Windows XP Professional and any necessary applications. This can be automated by using disk-imaging software.
7. Run LoadState.exe as administrator to restore the user settings. (You can do this as a scheduled task running in the administrator context.) When the user logs on, the last of their user state data is reset.

 my question is how can it scan and store information and then ask to format the HD? where is the infomration saved? and how is it saved? the files themselves? pointers? i'm sorry i just never used it before.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23655698
I have never used it before either, but I would be *very* surprised if it actually wiped any data from the disk :-)

My assumption would be that points 1 through 5 are done to back up the profile, but point 6 is a process that the administrator does of their own accord.  In my situation, we build a "new" machine with an image, and therefore have acecss to both machines side-by-side.  We would copy the the profile from the "old" computer, and have the "new" computer already available (through the point 6 process), and would perfrom step 6 on the new computer.

So, at step 5, we would back up the profile to a network location, or a USB drive or external hard drive.

It's the first time that I've seen the User State Migration Tool, so I'm going to be looking into it, hopefully today, to help streamline our PC Refresh process.

In your case though, you're trying to migrate profiles from one user account to another, on a different domain, which will have a different SID, correct?  In that case, I'll need to look at how to "remap" a user profile to a different SID....

Regards,

Rob.
0
 

Author Comment

by:johnnyjonathan
ID: 23661424
correct, different SID, however same computer and same OS
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23665390
Right, so while I haven't tested this, here is the help from the MoveUser.exe tool:

=============================================================================
Command Line Syntax:

  moveuser <user1> <user2> [/y] [/c:computer] [/k]

Description:

  moveuser.exe changes the security of a profile from one user to another.
  This allows the account domain to change, and/or the user name to change.

Arguments:

  user1    Specifies a user who has a local profile.
  user2    Specifies the user who will own user1's profile. This
           account must exist.
  /y       Allow overwrite of existing profile.
  /c       Specifies the computer to make the changes to.
  /k       Specifies if user1 is a local user, then the user account
           should be kept.

  Specify domain users in DOMAIN\USER format.  Specify only USER for
  local accounts.
=============================================================================

This suggests that if you run
moveuser <OLDDOMAIN>\<OldUser> <NEWDOMAIN>/<NewUser> /y

and then do not use the old account anymore, the new account should pick up that same profile.

I'm not quite sure how it works, but give that a shot....

Regards,

Rob.
0
 

Author Comment

by:johnnyjonathan
ID: 23724547
Thank you Rob, i'll be back on Saturday from my vacation and i will try this out.
0
 

Author Comment

by:johnnyjonathan
ID: 23774155

Rob,
thank you.

I have checked and the syntax  of moveuser <OLDDOMAIN>\<OldUser> <NEWDOMAIN>/<NewUser> /y

It does the job wonderfully! (only from local admin permissions)

Now here is the issue, i need the users to do this on their own, is there anyway to incorporate this into a script that will find the user in the old domain, fill in the syntax , then find the user in the new domain (not the same username) and fill in the syntax as well.

or, to make things easier, a script that will ask to input an old user and a new user with the old domain and new domain names remain constant. once the user's input their usernames the script will run the moveuser command.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 2000 total points
ID: 23781253
Does the moveuser work when a normal user is logged in though?

You can try this script....you'll need to put in your old domain name and new domain name into the script.

The command prompt will show the result of the MoveUser command. If you're happy with that, change the cmd /k to cmd /c and change strCommand, 1, True to strCommand, 0, True to have the command prompt hidden.

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
strOldDomain = "OLDDOMAINNAME"
strNewDomain = "NEWDOMAINNAME"
strOldUsername = InputBox("Enter your old username on " & strOldDomain & ":", "Old Username")
strNewUsername = InputBox("Enter your new username on " & strNewDomain & ":", "New Username")
strCommand = "cmd /k \\server\tools\moveuser.exe " & strOldDomain & "\" & strOldUsername & " " & strNewDomain & "\" & strNewUsername & " /y"
objShell.Run strCommand, 1, True
MsgBox "Done."

Open in new window

0
 

Author Comment

by:johnnyjonathan
ID: 23788301
move user won't work if one of the user's being migrated is logged in.
and yes the script worked very well! great job thank you!
0
 

Author Closing Comment

by:johnnyjonathan
ID: 31547134
Great help and explenations from Rob as always, your very kind and proffesional!
0
 

Author Comment

by:johnnyjonathan
ID: 23788375
Also, is there anyway i can tell the script to take the moveuser.exe localy in case it can't find it on the network?
or visaversa?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23789313
Hey, thanks for the grade.

>> is there anyway i can tell the script to take the moveuser.exe localy in case it can't find it on the network?

Yes, you can do that....have a look at the following code....

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strMoveUserNetwork = "\\server\tools\moveuser.exe"
strMoveUserLocal = objShell.ExpandEnvironmentStrings("%SYSTEMROOT%")  & "\System32\MoveUser.exe"
strOldDomain = "OLDDOMAINNAME"
strNewDomain = "NEWDOMAINNAME"
strOldUsername = InputBox("Enter your old username on " & strOldDomain & ":", "Old Username")
strNewUsername = InputBox("Enter your new username on " & strNewDomain & ":", "New Username")
If objFSO.FileExists(strMoveUserNetwork) = True Then
	strCommand = "cmd /k " & strMoveUserNetwork & " " & strOldDomain & "\" & strOldUsername & " " & strNewDomain & "\" & strNewUsername & " /y"
	objShell.Run strCommand, 1, True
	MsgBox "Done."
ElseIf objFSO.FileExists(strMoveUserLocal) = True Then
	strCommand = "cmd /k " & strMoveUserLocal & " " & strOldDomain & "\" & strOldUsername & " " & strNewDomain & "\" & strNewUsername & " /y"
	objShell.Run strCommand, 1, True
	MsgBox "Done."
Else
	MsgBox "Unabel to find MoveUser.exe"
End If

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question