If my script were in powershell it would be a lot like that, especially if the source domain were not a trusted domain.  In the ChangeOwner method I use 1 as the second parameter because I want any existing profile for the new owner to be deleted.  In your case, the new owner would not have an existing profile unless they log onto the computer after it is joined to the new domain and before you migrate the old profile.

I tend to use vbscript because I like the command line argument processing more and I do a lot of work from the Command Prompt command line.

Your requirements point out a weakness in my original script.  It assumed that both the source domain and target domain were known to the computer.  I think I can remedy that without too much new code.  I can design it so the original user can be specified by SID, profile directory name or by domain username.  I will work on it tonight.  If you would like me to make the script available on http://msu.edu/~ozminski, let me know.

-Stefan

On 12/3/2014 15:03, Jesse Howard wrote:
[log in to unmask]" type="cite">

Was it something like this?

>$OriginalUser = gwmi win32_userprofile -ComputerName testbox123 -Filter "SID = 'S-1-5-21-2849508690->365014496-115750160-1011'"
>$NewUser = get-wmiobject "Win32_UserAccount WHERE Name='xxxxxxx'"
>$Profile = gwmi win32_userprofile -ComputerName testboxcpc -filter "SID='$($OriginalUser.SID)'"
>$Profile.ChangeOwner($NewUser.SID, 0)

 

Jesse Howard

 

IT Administrator

Michigan State University Press

[log in to unmask]