Domain Migration Automation

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?
johnnyjonathanAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
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
 
johnnyjonathanAuthor Commented:
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
 
RobSampsonCommented:
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
johnnyjonathanAuthor Commented:
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
 
RobSampsonCommented:
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
 
johnnyjonathanAuthor Commented:
correct, different SID, however same computer and same OS
0
 
RobSampsonCommented:
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
 
johnnyjonathanAuthor Commented:
Thank you Rob, i'll be back on Saturday from my vacation and i will try this out.
0
 
johnnyjonathanAuthor Commented:

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
 
RobSampsonConnect With a Mentor Commented:
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
 
johnnyjonathanAuthor Commented:
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
 
johnnyjonathanAuthor Commented:
Great help and explenations from Rob as always, your very kind and proffesional!
0
 
johnnyjonathanAuthor Commented:
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
 
RobSampsonCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.