Citrix Virtual Apps and Desktops Sync Script

Using our synchronization script, you can automatically populate the ControlUp organizational tree with your Citrix Virtual Apps and Desktops. 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.
  • 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.
  • The ControlUp monitor must be version 8.1.5.600 or higher.
  • 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 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 \<path to the file>\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.
Name Description
FolderPath *Mandatory. The target folder in the ControlUp organizational tree to save these objects.
preview Displays the expected results without committing any changes to the ControlUp environment.
delete Enables the script to execute removing objects from the ControlUp organizational tree. Use with the preview parameter to see the proposed changes before making them.
logfile Specify a text file to log the output. Can be used for debugging and with the preview parameter to see the proposed changes. Log data is appended to this file with each run of the script.
siteName Specify a ControlUp Monitor site to assign the objects. Default value: default
Brokers A list of Brokers to contact for Delivery Groups and Computers to sync. Specify multiple brokers in a comma separated list.
These Brokers act as
delivery controllers and know what resources are available for which users. 

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 addBrokersToControlUp parameter.

includeDeliveryGroup

Include only these specific Delivery Groups to be added to the ControlUp tree. Specify multiple Delivery Groups in a comma separated list.
- If you do not enter a value here, all detected Delivery Groups are captured and updated in the ControlUp tree.

- Wild cards values are supported. For example: specify "Epic*" to include both "Epic North" and "Epic South".

- If you enter values for excludeDeliveryGroup parameter, the 'exclude' supersedes any values entered here and will not 'include' them.

excludeDeliveryGroup

Exclude specific delivery groups from being added to the ControlUp tree. Specify multiple Delivery Groups to exclude in a comma separated list.

- Wild cards values are supported. For example: specify "*CGY" to exclude both "Epic CGY" and "Cerner CGY".

- If you enter values for includeDeliveryGroup, this 'exclude' supersedes any values entered there and will not 'include' them.

addBrokersToControlUp 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. If this parameter is omitted, then Broker machines will not be moved or added to your ControlUp tree.
enabledOnly Include only Delivery Groups that are enabled.
MatchEUCEnvTree 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 FolderPath. See below for details on how the structure is added to ControlUp if this parameter is enabled.

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:

$SiteName - |    
  |- Delivery Groups - |  
  | |- DG1 - |
  |   |- Machine001
  |- Brokers - |  
    |- Broker001  

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. TreeBrokersDGs.png

2. Set up a Windows Scheduled Task

Follow the steps in this article 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.

LogOnAsABatch.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. ADServiceAccount.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

 

1-on-1 Demo
Schedule now
Price Quote
Get it now
Need a Script?
Get it here
Powered by Zendesk