How vCenter handles custom Sysprep.inf files

I ran into an issue the other day as I was trying to deploy a VM from from a template using the vCenter Customization Specification Manager.  I was trying to use a custom Sysprep.inf file that would automatically have the newly created VM join my AD domain and placed in a specific OU. 

Now, when I Sysprep’d the VM normally with my custom .inf file, everything worked fine.  But importing that exact .inf file into vCenter and deploying the VM from a template, the Sysprep failed.  So I had some digging to do, and here’s what I found out.

First, vCenter doesn’t actually store Sysprep.inf files.  Rather, vCenter stores the configuration parameters in XML and then generates the Sysprep.inf file on the fly during the deployment process.  (This part I actually already knew, the next part I didn’t).

Second, and most importantly, when importing a customized Sysprep.inf file, vCenter does not store each parameter as a separate XML element.  So for example, given the following custom text …

[Identification]
JoinDomain=mydomain.com

DomainAdmin=administrator

DomainPassword=1234

MachineObjectOU="OU = MyOU,DC = mydomain,DC = com"

 
I thought this would be stored in the normal, expected format, like this …

<JoinDomain>mydomain.com</JoinDomain>

<DomainAdmin>administrator</DomainAdmin>

<DomainPassword>1234</DomainPassword>

<MachineObjectOU>"OU = MyOU,DC = mydomain,DC = com" </MachineObejctOU>

But it turns out, when importing sysprep.inf files, vCenter stores the parameters as a single XML element with a modified <_type> element like this …

<_type>vim.vm.customization.SysprepText</_type>

<value> [Identification] JoinDomain=mydomain.com DomainAdmin=administrator DomainAdminPassword=1234 MachineObjectOU="OU = MyOU,DC = mydomain,DC = com"</value>

There’s a couple important points to note here:

  1. vCenter only stores the XML this way when importing a sysprep.inf file.  When using the customization wizard, vCenter generates XML which is formatted the normal way. 
  2. The first element, <_type>, contains the value vim.vm.customization.SysprepText.  When using the wizard, the value for this element is vim.vm.customization.Sysprep (without the trailing “Text”).
  3. When the XML is stored this way, whitespace matters!  Notice how whitespace is the delimiter in the <value> element?  And notice the spaces in the MachineObjectOU parameter?  Removing the spaces did the trick.
One comment Add yours
  1. Unfortunately, when importing sysprep.inf files, there doesn't seem to be any way to join the VM to the domain using the VM name.

Leave a Reply

Your email address will not be published. Required fields are marked *