Loading…

vCloud Trick – Joining a Domain and Specifying a Machine OU

NOTE: This is no longer required in vCD 5.1 & above!

This is one of those situations where I really start to hate computers!  I was working with vCloud Director with a goal of having a winders VM run through guest customization, change the name, get a fixed IP from the network pool, join an Active Directory Domain and move to a specific OU in the AD.

The Problem

There is a spot in the VM properties to specify a domain to join. You can use the settings specified in the organization or enter the domain information directly.

Specifying a Domain

Looks pretty easy, right? Yeah, but it doesn’t work as expected. It only seems to actually work if the VMs are getting DHCP addresses. Apparently, VMware Tools doesn’t enable the NIC if you specify an IP address, so we cannot contact DNS or the domain. Try to tell a Network guy that he has to use DHCP for servers. Some of them just don’t get it. Also, there is no way to specify a different OU, so the system ends up in the Computers container.

The Advertised (But Non-Working) Solution

I found some instructions to use the following syntax in the guest customization script. I figured that I could use the old-school netdom.exe command to both join a domain and move to the desired OU. So this is what I created:

123456if “%1%” == “precustomization” (   goto end) else if “%1%” == “postcustomization” (   netdom join %COMPUTERNAME% /domain:dclabs.local /ou:OU=vCloud,DC=dclabs,DC=local /userd:dclabs\administrator /passwordd:**** /reboot):end

Just like the original problem, this only works if the VM gets a DHCP address. Still not good. The only good news is that if the machine gets a DHCP address, it ends up in the proper OU, so I know the command syntax is correct.

The (Working)Solution

I don’t know how, but somehow, I remembered that the “customization” and “post customization” variables came from Lab Manager. I also remember that it also had some issues and Microsoft has a cool solution to post sysprep scripting.

First, create a CMD script in the following directory:
%windir%\Setup\Scripts\SetupComplete.cmd

Then, add the netdom.exe command to the script.

1netdom join %COMPUTERNAME% /domain:dclabs.local /ou:OU=vCloud,DC=dclabs,DC=local /userd:dclabs\administrator /passwordd:*** /reboot

This solution works!