Cloning XenApp 6.5 on ESX

We recently started deploying XenApp 6.5 using VMWare ESX.  Our typical process is to convert to template and then use ESX deploy from template procedures.  VMWare conveniently built in a sysprep-like process that runs after the VM boots up and joins the network.  In XenApp 4.5 the process worked perfectly with the XenAppPrep command line tool.  The server would boot and join the farm with a unique name.  Sadly with XenApp 6.0 and 6.5 that doesn’t seem to be quite right.  Starting with XenApp 6.0 Citrix did away with XenAppPrep and now expects you to use their GUI to prepare servers for cloning.  They also have a fairly weak article that you can find here that supposedly describes how to clone.  Here’s the problem… they give you no real details. 

What happens on ESX is that the server spins up from the template with some temporary name.  Because it comes all the way up and joins the farm (whether you join the domain or not!) that name is what it joins under.  It then goes back down and goes through the ESX sysprep and comes up again with the correct name.  It joins the farm yet again with that name, leaving a bad entry for the temp name in place.  Yes, you can just delete the bogus entry.  Having too much experience with Citrix database corruption, I don’t like putting in and deleting bogus data when I can help it.  Citrix support was no real help, and could not actually provide us with a proper cloning method on ESX.  So thankfully we came up with our own.

First I am assuming you have a knowledge of the VMWare process to template servers.  One of the options in that process is to run a script post sysprep to do any other cleanup.  We will use that option to make sure our servers only join the farm once they are completely built.

1) Prep server for cloning with the GUI process like Citrix wants.
2) Set the IMA service to Disabled in the services.
3) Create a runonce script on the server which sets the service to Automatic and starts it
3) Template the server
4) Deploy from template... in the settings choose to run the runonce script as an additional step
5) Profit!

Yes, its more complicated than it used to be.  Sadly there’s no real option to do otherwise.  For an example of a script you could use:

sc config IMAService start= auto

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\windows\temp\Set-New-STA.ps1

The last part of that script is a cool powershell process that makes sure your STA ID is correct.  For more information see this great post!  That’s it!  Works like a champ every time.

, , ,


  • Sean says:


    Thanks for the tips. A few questions;

    1) Regarding the source VM you intend to turn into a template, should this remain joined to the domain, or be pulled off prior to cloning it to a template? Is there a best practice around this?

    2) Does the source VM need to be cloned to a template, or can this be left as a regular VM and cloned? Reason being, it would be helpful to leave the source VM as a working XenApp server if possible. If I followed these steps without turning the VM into a template, what would the difference be?

    3) In my first attempt I did follow the steps as outlined above, and the cloning process seemed to work, however once I powered on my clone and logged in the server just sat there and never brought me to the desktop. I rebooted, and got the same result. I could remote computer manage it and view the event log, services, etc, and everything looked fine, no glaring errrors or issues. The only weird thing I noticed was it did not seem to run my script I placed in the RunOnce section of the VM customization wizard. I can’t see why this would cause the behavior above though Any thoughts? I’m cloning again right now to see if I can get a different result.

    • Paul says:

      Hey Sean, sorry for the delay. Didn’t realize I had comments turned off 🙂

      1) We leave it domain joined. I know some people recommend pulling it and then using the VCenter scripting to join it but we haven’t found it to be super necessary.

      2) We clone to a template because then you can leave the original one up to be patched. You just have to remember to follow the steps prior to reconverting to template.

      3) I have seen it do that when it had communication issues with the DC. Not sure what NIC you are using, I recommend VMXNET3 if possible.


Leave a Reply

XHTML: You can use these tags: <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="">