VMware Horizon Sync Scripts

The Horizon Sync Scripts Scheduled Task must be created on the ControlUp Monitor server.

Before creating the scheduled task, you must:

  • Prepare the Task Scheduler to run Horizon Scripts. For more information, see here.
  • Open the ControlUp Monitor Server.
  • Create a permanent folder for the task schedule.
  • Download the Horizon_Sync.ps1 script from our GitHub repository
  • Create an exceptions.txt file (not mandatory).

Argument Description

Argument:

-file "C:\Horizon_Sync_Script\Sync_ControlUP_With_ Horizon_View_v2.ps1" -hvconnectionserverfqdn "horizon.controlup.demo" -targetfolderpath "controlup demo\il datacenter\virtual desktops\horizon demo" -pooldivider "Desktop Pools" -rdsdivider "RDS Farms" -exceptionfile "C:\Horizon_Sync_Script\exceptions.txt"

Description:

  1. file - (Mandatory) - "C:\Horizon_Sync_Script\Sync_ControlUP_With_ Horizon_View_v2.ps1"
    The location of the Sync PS Script can be changed to any desired location.
  2. hvconnectionserverfqdn - (Mandatory) - "horizon.controlup.demo"
    FQDN of a Connection Server.
  3. targetfolderpath - (Mandatory) - "controlup demo\il datacenter\virtual desktops\horizon demo"
    The path of the folder where all objects are placed in the ControlUp organizational tree.
  4. pooldivider - (Mandatory) - "Desktop Pools"
    The name of the folder where the Desktop Pools are placed in the ControlUp organizational tree.
  5. rdsdivider - (Mandatory) - "RDS Farms"
    The name of the folder where RDS Farms are placed in the ControlUp organizational tree.
  6. exceptionfile - (Not mandatory) - "C:\Horizon_Sync_Script\exceptions.txt" 
    the location of a text file with the list of DNS names for machines you do not want to be added to the ControlUp organizational tree.
    mceclip1.png

    Sync_ControlUP_With_ Horizon_View_v5.ps1 (40 KB)

Adding Managed Machines

To add Managed Machines in ControlUp, two distinct operations are required:

  1. Adding the machine to the ControlUp organization.
  2. Deploying the ControlUp Agent on the machine.

Each of these actions can be completed either manually or automatically as follows:

  • Manually – Using the ControlUp Console
  • Automatically – Using PowerShell scripts and an MSI package

This article covers the scripts required for getting ControlUp running with managed machines automatically.

Auto Adding Machines Installed with the MSI Package

To support the dynamic nature of Horizon environments, where desktop pools are constantly updated, ControlUp has created sync scripts that make the machine adding process easy and automated.

The machine running the monitor will need to go through a short preparation process in order to run several PowerShell scripts.

Installed software prerequisites:

  • PowerShell 5.0
  • PowerShellCLi 11.0 or later (To install the PowerShellCLi, type Install-Module VMware.PowerCLI in the PowerShell command line.)
  • The controlup.cli PowerShell module (To install the controlup.cli, type install -module controlup.cli in the PowerShell command line.)

To prepare the monitor for running the Horizon Sync Script:

  1. Open ControlUp Console and click Script Actions and the Scripts Management screen appears.
    mceclip4.png
  2. From the Scripts Management screen, search for the “Create credentials for Horizon View scripts” and then click Add Script, and the Add a Shared Script Action popup appears.
  3. Click the Accept the terms checkbox and click OK and the script are added, and you are returned to the Scripts Management screen.
  4. From the Scripts Management screen, search for the “Install Hv.Helper module for Horizon View scripts” and then click Add Script, and the Add a Shared Script Action popup appears.
  5. Click the Accept the terms checkbox and click OK and the script are added, and you are returned to the Scripts Management screen.
  6. Click Close and the ControlUp Console grid appears.
  7. From the ControlUp Console grid, locate the monitor server you would like to prepare and Right-click over it, and the Management Actions menu appears.
  8. Hover over Script Actions and select Create credentials for Horizon View scripts and the Create credentials for Horizon View popup appears.
    mceclip5.png
  9. From the Credentials dropdown select the user to be used to run the monitor account. That is the account you used while setting up the monitor's primary domain identity.
  10. In the Command Line Arguments text box enter the credentials you used to connect to the Horizon Connection Server while adding the EUC environment to the console.
  11. Click OK and the Action Results Screen appears.
  12. In the Errors tab in the Action Results Screen appears, check that the action is complete with no errors. If the action is successful a credentials XML file will be created under C:\ProgramData\ControlUp\ScriptSupport
  13. Close the screen Action Results Screen and you are returned to the ControlUp Console grid.
  14. Run the second script by hovering over Script Actions and Select Install Hv.Helper module for Horizon View scripts and the Action Results screen appears. Make sure the action is complete with no errors and the scripts are applied.

Creating a Scheduled Task to Run the Script

Once the monitor machine is prepared, a Windows Task Scheduler task must be created in order to regularly run a sync script.

The following procedures must be performed prior to creating the Task Scheduler:

  1. Download the PS script linked here.
  2. Create a new folder, for example, Horizon_Sync_Script, and place the file in this folder.
  3. If you would like to exclude pools from being added to the console, create an “exceptions.txt” file with the names of the pools you would like to exclude, and place it in the folder.
  4. Create a Task Scheduler that will run this script daily.

Creating a Task Scheduler for Automatically Adding Horizon Machines via a Script

The Task Scheduler for automatically adding Horizon machines using a script must be created on the ControlUp Monitor server machine.

To Create the Task Scheduler:

  1. Open the Task Scheduler.
    mceclip6.png
  2. In the Task Scheduler window, go to the Actions panel and click Create Task. The Create Task window is displayed.
    mceclip7.png
  3. In the General tab, name the newly created task “ControlUp Horizon Sync”.
  4. In the Security options, Click Change Users or Group and select the service account used for running the monitor.
  5. Select Run whether a user is logged on or not, and add a description if desired.
    mceclip9.png

    Set the triggers:
  6. To add a new trigger, select the Triggers tab and click New.
    mceclip10.png
  7. Click Begin in the task drop-down box and select On a schedule and select Daily and set a daily time to start the task in Task Scheduler in the ‘Recur every’ text box to 1. Click OK and the trigger is set.

    Note: The time you set will also be the time the task runs daily.
    mceclip11.png

    Set a task action:

  8. Select the Actions tab, and click New and the Set Actions popup appears.
    mceclip12.png

  9. In the Set Actions popup, select Start a program from the dropdown menu.

  10. Click .. and choose powershell.exe (located in: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe).
    Add the following arguments to the template below:
    -file "[FILE NAME AND PATH]" -hvconnectionserverfqdn "[CONNECTION SERVER FQD]" -targetfolderpath "[ORG TREE FOLDER PATH]" -pooldivider "[ORG TREE DESKTOP POOLS FOLDER NAME]" -rdsdivider "[RDS FARMES FOLDER NAME]" -exceptionfile "[EXEPTION FILE NAME AND PATH]"
    mceclip13.png

    You will need to modify the arguments depending on your desired outcome.

  11. Click OK and the actions are set.

    Conditions setting: 

  12. Leave the task conditions with the default values and click OK.
    mceclip14.png

    Settings Tab: 

  13. In the Settings tab, make sure that the following are checked:
    mceclip15.png

  14. Click OK and the settings are set.

    Argument Description:

    The following is a description of the argument variables used in the script, that will allow you to control the outcome according to your needs.

    The Argument:

    -file "C:\Horizon_Sync_Script\Sync_ControlUP_With_ Horizon_View_v2.ps1" -hvconnectionserverfqdn "horizon.controlup.demo" -targetfolderpath "controlup demo\il datacenter\virtual desktops\horizon demo" -pooldivider "Desktop Pools" -rdsdivider "RDS Farms" -exceptionfile "C:\Horizon_Sync_Script\exceptions.txt"

    The Description:

    • file - (Mandatory) - "C:\Horizon_Sync_Script\Sync_ControlUP_With_ Horizon_View_v2.ps1" -
    • The location of the Sync PS Script can be changed to any desired location.
    • hvconnectionserverfqdn - (Mandatory) - "horizon.controlup.demo" - The FQDN of a Connection Server.
    • targetfolderpath - (Mandatory) - "controlup demo\il datacenter\virtual desktops\horizon demo" - The path of the folder where all objects will be placed in the ControlUp organizational tree.
    • pooldivider - (Mandatory) - "Desktop Pools" - The Name of the folder where the Desktop Pools will be placed in the ControlUp organizational tree.
    • rdsdivider - (Mandatory) - "RDS Farms" – The name of the folder where RDS Farms will be placed in the ControlUp organizational tree.
    • exceptionfile - (Not mandatory) - "C:\Horizon_Sync_Script\exceptions.txt" – The location of a text file with the list of DNS names for machines you DO NOT want to be added to the ControlUp organizational tree.
1-on-1 Demo
Schedule now
Price Quote
Get it now
Need a Script?
Get it here
Powered by Zendesk