Citrix XenDesktop Image Management Script

Currently XenDesktop does not support multi-site deployment. If the administrator has same images, they have to manually keep all the images in sync. Citrix has come up with a way to automate this process.

Beside the general XenDesktop components, there are the following few additional components required to perform Image Management.

Note: These additional components are not part of either XenDesktop or XenServer.

Control Machine

Control Machine is Windows OS which has Desktop Studio (for XenDeskop SDK) and XenServer PowerShell SDK installed. This machine hosts the PowerShell script (Control Script) which manages the image synchronization and updating of slave Catalogs.

Control Script

The Control Script is a PowerShell script which runs on the Control Machine. It interacts with the user by getting the Master Site and Slave Sites details and keep them updated with the progress and result of the sync process.

Sync Script

The Sync Script is a bash script started by the control script and is run in Dom0 on the master site’s XenServer Pool-Master to copy the consolidated image’s VHD file across to a XenServer residing on the slave site. rsync-over-SSH is used to complete this task.

The rationale for placing the sync script on the hypervisor itself rather than on the control machine is that neither of the XenDesktop or XenServer APIs currently provides a mechanism for copying files across hosting units located in different pools or sites.

The sync script is started by the control script on the control machine and takes the following parameters.

  • VDI Name
  • Arbitrary number of Host/SR pairs as targets for the synchronization.

The following is an overview of the sync script’s operations:

    • Managed: True
    • Read-Only: False
  • Resolve the VDI to all possible candidate VHD files on the host’s SRs.
  • Locate the youngest candidate VHD for the given VDI. The assumption being that the youngest file is the product of the most recent consolidation.
  • Determine the mount point of the target host’s SR to copy the VHD file to.
  • Use rsync to initiate the synchronization process.
  • Attempt to verify that the VHD file has indeed been copied to the target.
  • Change the following flags on the VHD file for use in reconsolidation on the slave site:


  • The sync script requires interaction with hosts that have visibility of the file-systems associated with the SRs involved in this process.
  • The remote target must be visible over ssh from the host pushing the VHD out.
  • The host initiating the transfer must have been setup for SSH Public Key Authentication for a fully automatic schedulable synchronization.
  • The mount-point for the remote SR must have necessary space and permissions to allow the VHD copy.

Click here to learn more about the Citrix XenDesktop Image Management Tool and download