---
title: "Legacy Citrix Virtual Apps and Desktops Sync Script"
slug: "citrix-virtual-apps-and-desktops-sync-script"
updated: 2025-07-03T12:06:39Z
published: 2025-07-03T12:06:39Z
canonical: "support.controlup.com/citrix-virtual-apps-and-desktops-sync-script"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.controlup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy Citrix Virtual Apps and Desktops Sync Script

:::(Warning) (Important)
The maintenance of the CVAD sync script has been discontinued. We recommend using the [Universal sync script](/tim-reorg/docs/euc-synchronization-with-universal-sync-script){target="_blank"} instead.
:::

Using our synchronization script, you can automatically populate the ControlUp organizational tree with your [Citrix Virtual Apps and Desktops](https://www.controlup.com/solutions/citrix/) environment. Our sync script is run as a Windows scheduled task so that when you add or remove machines, those changes are automatically reflected in the organizational tree in ControlUp. You don't have to make any of those changes manually. When the script is run, your ControlUp organization reflects your current Citrix VDI for monitoring and remediation.

 * The sync script is written in PowerShell and stored in our [GitHub repository](https://github.com/controlup/environment-scripts/tree/master/Environment_Synchronization_Scripts) .
 * You set the Windows scheduled task to run the sync script on the ControlUp monitor machine.  


### Prerequisites

 * The sync has to be performed on a machine which has the ControlUp monitor component installed. You can read about [Adding a ControlUp Monitor](/tim-reorg/docs/adding-a-controlup-monitor).
* The user running the scripts must have a local profile on the ControlUp monitor machine. Ensure that the same user logs onto the machine at some point before running the scripts.
 * The user running the script must be an Active Directory service account that has at least read permission access to the Citrix studio.

### 1. Access the scripts from our GitHub repository
You download the sync scripts from our GitHub repository of [environment scripts](https://github.com/controlup/environment-scripts/tree/master/Environment_Synchronization_Scripts) which also includes synchronization scripts for other environments.

 1. Download the following scripts:
**CTX_Sync.ps1**
**Build-CUTree.ps1**
 2. Copy these scripts to the machine running the ControlUp monitor. These scrips must reside in the same folder on the monitor machine.
 3. ***Optionally*** , in a PowerShell window, run this command to see the script's parameters, their descriptions, and default values:
 ```
get-help \&lt; *path to the file* &gt;\CTX_Sync.ps1
```

Here are the parameters in the sync script **CTX_Sync.ps1.**	  These are the parameters to assign when adding the argument in step [2.Set up a Windows Scheduled Task.](#2-set-up-a-windows-scheduled-task) 
<table style="border-collapse: collapse; width: 98.8799%; height: 1080px;" border="1"><tbody><tr style="height: 22px;"><td style="width: 26.3067%; height: 22px;"><strong>Name</strong></td><td style="width: 74.7507%; height: 22px;"><strong>Description</strong></td></tr><tr style="height: 44px;"><td style="width: 26.3067%; height: 44px;"><strong>FolderPath</strong></td><td style="width: 74.7507%; height: 44px;"><span>*<strong>Mandatory</strong>. The target folder in the ControlUp organizational tree to save these objects.</span></td></tr><tr style="height: 44px;"><td style="width: 26.3067%; height: 44px;"><div><div><strong>Preview</strong></div></div></td><td style="width: 74.7507%; height: 44px;"><span>Displays the expected results without committing any changes to the ControlUp environment.</span></td></tr><tr style="height: 66px;"><td style="width: 26.3067%; height: 66px;"><div><div><strong>Delete</strong></div></div></td><td style="width: 74.7507%; height: 66px;"><span>Enables the script to execute removing objects from the ControlUp organizational tree. Use with the <strong>preview</strong> parameter to see the proposed changes before making them.</span></td></tr><tr style="height: 44px;"><td style="width: 26.3067%; height: 44px;"><div><div><strong>LogFile</strong></div></div></td><td style="width: 74.7507%; height: 44px;"><span>Specify a text file to log the output. Can be used for debugging and with the <strong>preview</strong> parameter to see the proposed changes. Log data is appended to this file with each run of the script.</span></td></tr><tr style="height: 22px;"><td style="width: 26.3067%; height: 22px;"><div><div><strong>Site</strong></div></div></td><td style="width: 74.7507%; height: 22px;"><span>Specify a ControlUp Monitor site to assign the objects. Default value: default</span></td></tr><tr style="height: 181px;"><td style="width: 26.3067%; height: 181px;"><strong>Brokers</strong></td><td style="width: 74.7507%; height: 181px;"><span><span>A list of Brokers to contact for Delivery Groups and Computers to sync. Specify multiple brokers <span class="pl-c">in a comma-separated list</span>.<br>These Brokers act as </span></span>delivery controllers and know what resources are available for which users.&nbsp;<p>If you have multiple different Citrix environments, for example, you may have multiple Brokers for testing and production environments, we recommend listing the multiple Brokers and using the <strong>addBrokersToControlUp</strong> parameter.</p></td></tr><tr style="height: 232px;"><td style="width: 26.3067%; height: 232px;"><strong><span>includeDeliveryGroup</span></strong></td><td style="width: 74.7507%; height: 232px;"><p><span class="pl-c">Include only these specific Delivery Groups to be added to the ControlUp tree. <span>Specify multiple Delivery Groups in a comma-separated list. <br>- If you do not enter a value here, all detected Delivery Groups are captured and updated in the ControlUp tree. </span></span></p><p><span class="pl-c">- Wild cards values are supported. For example: specify "<strong>Epic*</strong>" to include both "Epic North" and "Epic South".</span></p><p><span class="pl-c">- If you enter values for <strong>excludeDeliveryGroup </strong>parameter, the 'exclude' supersedes any values entered here and will not 'include' them.</span></p></td></tr><tr style="height: 166px;"><td style="width: 26.3067%; height: 166px;"><strong><span><span class="pl-c">excludeDeliveryGroup</span></span></strong></td><td style="width: 74.7507%; height: 166px;"><p><span>Exclude specific delivery groups from being added to the ControlUp tree. <span class="pl-c">Specify multiple Delivery Groups to exclude in a comma-separated list.<br></span></span></p><p>- <span class="pl-c">Wild cards values are supported. For example: specify "<strong>*CGY</strong>" to exclude both "Epic CGY" and "Cerner CGY".</span></p><p><span class="pl-c">- If you enter values for <strong>includeDe<span>liveryGroup</span></strong>, this 'exclude' supersedes any values entered there and will not 'include' them.</span><span class="pl-c"></span></p></td></tr><tr style="height: 87px;"><td style="width: 26.3067%; height: 87px;"><strong><span><span class="pl-c">addBrokersToControlUp</span></span></strong></td><td id="LC40" class="blob-code blob-code-inner js-file-line" style="width: 74.7507%; height: 87px;"><span class="pl-c">Add brokers to the ControlUp Tree. This optional parameter can be specified if you prefer this script to add broker machines as they are detected. <span>If this parameter is omitted, then Broker machines will not be moved or added to your ControlUp tree.</span></span></td></tr><tr style="height: 21px;"><td style="width: 26.3067%; height: 21px;"><strong>enabledOnly</strong></td><td id="L41" class="blob-num js-line-number" style="width: 74.7507%; height: 21px;" data-line-number="41"><span>Include only Delivery Groups that are enabled.</span></td></tr><tr style="height: 109px;"><td style="width: 26.3067%; height: 109px;"><strong><span>MatchEUCEnvTree</span></strong></td><td style="width: 74.7507%; height: 109px;"><span>Configures the script to match the same structure used by ControlUp for the EUC Environment Tree. If this parameter is omitted, the Delivery Group is added to the <strong>FolderPath</strong>. See below for details on how the structure is added to ControlUp if this parameter is enabled.</span></td></tr><tr style="height: 21px;"><td style="width: 26.3067%; height: 21px;"><div><div><strong>maxRecordCount</strong></div></div></td><td style="width: 74.7507%; height: 21px;"><div><div><span>Maximum number of items to request from a broker</span></div></div></td></tr><tr style="height: 21px;"><td style="width: 26.3067%; height: 21px;"><div><div><strong>batchCreateFolders</strong></div></div></td><td style="width: 74.7507%; height: 21px;"><div><div><div><div><span>Create&nbsp;folders&nbsp;in&nbsp;batches&nbsp;rather&nbsp;than&nbsp;individually</span></div></div></div></div></td></tr><tr><td style="width: 26.3067%;"><div><div><strong>force</strong></div></div></td><td style="width: 74.7507%;"><div><div><div><div><div><div><span>Force folder creation if the number exceeds the safe limit</span></div></div></div></div></div></div></td></tr><tr><td style="width: 26.3067%;"><div><div><strong>SmtpServer</strong></div></div></td><td style="width: 74.7507%;"><div><div><div><div><div><div><div><div><span>Smtp&nbsp;server&nbsp;to&nbsp;send&nbsp;alert&nbsp;emails&nbsp;from</span></div></div></div></div></div></div></div></div></td></tr><tr><td style="width: 26.3067%;"><div><div><strong>emailFrom</strong></div></div></td><td style="width: 74.7507%;"><div><div><div><div><div><div><div><div><span>Email&nbsp;address&nbsp;to&nbsp;send&nbsp;alert&nbsp;email&nbsp;from</span></div></div></div></div></div></div></div></div></td></tr><tr><td style="width: 26.3067%;"><div><div><strong>emailTo</strong></div></div></td><td style="width: 74.7507%;"><div><div><div><div><div><div><div><div><span>Email addresses to send an alert email to</span></div></div></div></div></div></div></div></div></td></tr><tr><td style="width: 26.3067%;"><div><div><strong>emailUseSSL</strong></div></div></td><td style="width: 74.7507%;"><div><div><div><div><div><div><div><div><span>Use SSL to send an email alert</span></div></div></div></div></div></div></div></div></td></tr></tbody></table>


**MatchEUCEnvTree Parameter**	  
If you enable this parameter in the Windows Scheduled Task argument running this sync script, any Delivery Group and Broker that is detected as added to your VDI is added to ControlUp as follows:
<table style="border-collapse: collapse; width: 74.7199%; margin-left: 0px; margin-right: auto;"><tbody><tr><td style="width: 14.8571%;">$SiteName -</td><td style="width: 27.4824%;">|</td><td style="width: 19.7642%;">&nbsp;</td><td style="width: 18.6388%;">&nbsp;</td></tr><tr><td style="width: 14.8571%;">&nbsp;</td><td style="width: 27.4824%;">|- Delivery Groups -</td><td style="width: 19.7642%;">|</td><td style="width: 18.6388%;">&nbsp;</td></tr><tr><td style="width: 14.8571%;">&nbsp;</td><td style="width: 27.4824%;">|</td><td style="width: 19.7642%;">|- DG1 -</td><td style="width: 18.6388%;">|</td></tr><tr><td style="width: 14.8571%;">&nbsp;</td><td style="width: 27.4824%;">|</td><td style="width: 19.7642%;">&nbsp;</td><td style="width: 18.6388%;">|- Machine001</td></tr><tr><td style="width: 14.8571%;">&nbsp;</td><td style="width: 27.4824%;">|- Brokers -</td><td style="width: 19.7642%;">|</td><td style="width: 18.6388%;">&nbsp;</td></tr><tr><td style="width: 14.8571%;">&nbsp;</td><td style="width: 27.4824%;">&nbsp;</td><td style="width: 19.7642%;">|- Broker001</td><td style="width: 18.6388%;">&nbsp;</td></tr></tbody></table>


Meaning that each Delivery Group is added as a separate line under a folder for Delivery Groups with each machine listed separately. And each Broker is added as a separate line under a folder for Brokers.

This is how this structure would look in your ControlUp organizational tree.
![ControlUp organization folder tree.](https://cdn.document360.io/098100b7-b9da-4bea-b4b9-017140ab863e/Images/Documentation/360017108618TreeBrokersDGs.png)




### 2. Set up a Windows Scheduled Task
Follow the steps in this [article](/tim-reorg/docs/auto-sync-environment-changes-into-controlup-s-organizational-tree) to create the Windows Scheduled Task but be sure to also follow these instructions for this specific sync script. In the Windows Local Security Policy, ensure that this user’s role has **Log on as a batch job**	  properties.
!['Log on as a batch job properties' window, containing 'CONTROLUP\ControlUp Service Account.](https://cdn.document360.io/098100b7-b9da-4bea-b4b9-017140ab863e/Images/Documentation/360015314878LogOnAsABatch1.jpg) 


#### Run the Script as an Active Directory Account
You must run the script as an Active Directory account that has at least read-only permission within the Citrix studio. We recommend creating a service account in your AD to run this sync script, and that AD account has to be accessible from the monitor machine.  
When scheduling to run the task, be sure to select:

 * **Run whether user is logged on or not**	  
 * **Run with highest privileges**	  

In this example below, the user account is CONTROLUP\svc_sync_citrix created for running this script in these tasks. You can see where to select the above options.
![Computer Management window with the configuration options described above.](https://cdn.document360.io/098100b7-b9da-4bea-b4b9-017140ab863e/Images/Documentation/360017037277ADServiceAccount.png)


#### Create the Add Task
Create a task for adding entities to the ControlUp organizational tree. Here's an example of the argument to use based on the parameters described above.
```
-ExecutionPolicy RemoteSigned -NoLogo -File "C:\CU Environment Sync Scripts\CTX_Sync.ps1" -folderPath "controlup demo\Virtual Desktops\XenDesktop 7.11" -logFile "C:\CU Environment Sync Scripts \CTX Sync.log" -Brokers cuxenddc01 -addBrokersToControlUp
```
In this example of the argument, you can see the following parameters:

 * **-folderPath**	  - controlup demo\Virtual Desktops\XenDesktop 7.11 
 * **-logFile**	  - C:\CU Environment Sync Scripts \CTX Sync.log
 * **-Brokers**	  - cuxenddc01 (only one listed)
 * **-addBrokersToControlUp**	  - included as an optional parameter


#### Create the Delete Task
Create another task for deleting from the ControlUp organizational tree any entities that have been deleted from your environment. Here's an example of the argument to use based on the parameters described above.
```
-ExecutionPolicy RemoteSigned -NoLogo -File "C:\CU Environment Sync Scripts\CTX_Sync.ps1" -folderPath "controlup demo\IL Datacenter\Virtual Desktops\XenDesktop 7.11" -logfile "C:\CU Environment Sync Scripts\CTX Sync Deletes.log" -Brokers cuxenddc01 -Delete -addBrokersToControlUp
```
