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 Password

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:

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 “precustomization” and “postcustomization” 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.

This solution works!

  1. My first time here. Awesome blog and super post. Well done.

  2. Hi, I’m having trouble joining a specific OU through vCloud Director, question on your solution. Should the script be added through the guest OS or VM through vsphere?

    • Mary –
      The script listed under the (Working) Solution must be specifically placed in %windir%\Setup\Scripts\SetupComplete.cmd

      This would be in the Windows Guest OS. The best thing would be to create the script in the VM Template with vSphere. You could also add it to a VM inside of vCD and then publish it to the catalog.

      Hope that explains it.

      Dave

  3. Doesn’t work for me, as far as I understand “SetupComplete.cmd” only runs is there I a fatal error which isn’t the case here.

  4. I have got asked few days back if this has changed in 5.1 & 5.5 by a customer of mine as both your post and one of my old ones ( http://www.virtualizationteam.com/cloud/vcloud-director-joining-vms-to-specific-active-directory-domain-ou.html ) were doing it using scripts. I have updated mine with a note stating this is no longer required in vCD 5.1 & above and was wondering if you don’t mind doing the same on your post as that will help reduce confusion of people installing the current version of vCD :).

    Thanks,
    Eiad

  5. I followed your steps and built a SetupComplete.cmd placed it in %windir%\Setup\Scripts\

    However, every time something gets deployed from my templates, the system name and IP address change, but the SetupComplete.cmd never fires off. If I launch it by hand, everything completes perfectly. Everything I can find simply stated to place it in the folder and windows will launch the scripts as part of its configuration process.

    I’m seeing this same behavior on XP, 7, 2008, and 2012 deployments. Any ideas?

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">