using Runonce to move VM to different OU

If you are using Horizon View and creating full clones, undoubtedly you’ve run into the issue of having the VM joining the domain but placed in the wrong OU.   To get around this you either moved it yourself, have a GPO do it or some VBScript.

After many searches and trial and errors, I’ve finally got it working in my environment.

In the customization specification, I have the VM join the domain using the UPN format, user@domain.com, then in the Runonce field I have the following:

cmd.exe /c dsmove -u user@domain.com cn=%computername%,cn=computers,dc=domain,dc=com -d domain.com -newparent "ou=NEW OU,dc=domain,dc=com" -p "P@ssword"

To get this to work, you’ll need to copy dsmove.exe and dsmove.exe.mui from a another computer that has AD tools installed.

You’ll need to copy dsmove.exe from c:\windows\system32 and dsmove.exe.mui from  c:\windows\system32\en-us and place them in the same folders on your image\template.

Please keep in mind this tested and verified on Windows 7,  other Windows versions may be different.  So please test thoroughly.

Hope this helps anyone using Horizon View using full desktops or manual pools.

%d bloggers like this:
Bitnami