# Citrix Virtual Apps and Desktops connector

{% hint style="warning" %}
This documentation references external sources. Nexthink does not have control over the accuracy of third-party documentation, nor any external updates or changes that might create inconsistencies with the information presented on this page. Please report any errors or inconsistencies to [Nexthink Support](https://support.nexthink.com/).
{% endhint %}

Nexthink Connector for Citrix Virtual Apps and Desktops (CVAD) retrieves important information about your Citrix environments, most notably the name of the Desktop Delivery Group to which the virtual machines belong. The connector ships with an accompanying live dashboard that you can download in a form of a library pack. Refer to the [Desktop Virtualization Optimization](https://edocs.nexthink.com/nexthink-infinity/infinity-specifications/desktop-virtualization-classic/desktop-virtualization-optimization-classic) extended documentation for more details.

This installation guide aims to help you install the connector for CVAD securely. Your security team should review the installation steps described in this document and adjust them to meet your organization’s security policy.

{% hint style="info" %}
Nexthink Connector for CVAD and Nexthink Collector work together to provide additional information about CVAD environments. This means that in addition to installing the Nexthink Connector for CVAD, you must also install Nexthink Collector on all virtual devices in your Citrix environment.
{% endhint %}

## Device fields <a href="#connectorforcitrixvirtualappsanddesktops-devicefields" id="connectorforcitrixvirtualappsanddesktops-devicefields"></a>

The connector for Citrix Virtual Apps and Desktops (CVAD) imports the following device virtualization fields.

| **Nexthink Field**               | **Description**                                                                                                   |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| Virtualization desktop pool name | The hardware characteristics of the associated VMs.                                                               |
| Virtualization desktop pool type | <p>The type of the desktop pool. Possible values are:</p><ul><li>shared</li><li>personal</li><li>pooled</li></ul> |
| Virtualization hostname          | The physical device hosting the VM. It may be empty for those machines hosted in a cloud vendor, such as Azure.   |
| Virtualization hypervisor name   | The hardware virtualization system which is being used.                                                           |
| Environment name                 | The name of the connector instance which enriches the virtual device.                                             |
| Desktop broker                   | The name of the desktop virtualization product used. In this case, `citrix_cvad`.                                 |
| Disk image                       | The name of the disk image used to deploy the VM.                                                                 |

## Nexthink connector server <a href="#connectorforcitrixvirtualappsanddesktops-nexthinkconnectorserver" id="connectorforcitrixvirtualappsanddesktops-nexthinkconnectorserver"></a>

To limit the risk of disrupting the Citrix Desktop Delivery Controller (DDC), Nexthink recommends installing the Nexthink Connector for CVAD on a separate server.

However, the expected impact to the DDC is minimal, therefore for proof-of-value installations this can be done directly on the Citrix server.

### Prerequisites <a href="#connectorforcitrixvirtualappsanddesktops-prerequisites" id="connectorforcitrixvirtualappsanddesktops-prerequisites"></a>

* Installed Windows PowerShell 5.1.
* Execution policy set to **bypass**.
* The following PowerShell modules:
  * [Logging 4.8.5](https://www.powershellgallery.com/packages/Logging/4.8.5)
  * [CredentialManager 2.0](https://www.powershellgallery.com/packages/CredentialManager/2.0)
* Installed Citrix Powershell SDK 2203 LTSR or newer. Refer to the [SDKs and APIs for Citrix Virtual Apps and Desktops 7 2203 LTSR](https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/2203-ltsr/sdk-api.html) documentation for the installation procedure using Citrix Studio.
* Joined domain.
* [Downloaded Nexthink Connector for CVAD](https://download.nexthink.com/integrations/Citrix+OnPrem+Connector/1.7.12/CitrixConnector-1.7.12.zip).
* The following accounts:
  * Citrix Read Only Account
  * Domain Account
  * Local user account on the machine

#### **URLs to allow through firewall/proxy for powershell `Install-Module`**

<table><thead><tr><th width="319">Purpose</th><th>URL</th></tr></thead><tbody><tr><td>PowerShell Gallery</td><td><code>https://www.powershellgallery.com</code></td></tr><tr><td>NuGet provider</td><td><code>https://www.nuget.org</code></td></tr><tr><td>NuGet API</td><td><code>https://api.nuget.org</code></td></tr><tr><td>CDN for packages</td><td><code>https://www.powershellgallery.com/api/v2/</code></td></tr><tr><td>Alternate NuGet V2 API</td><td><code>https://www.nuget.org/api/v2/</code></td></tr><tr><td>Certificate revocation</td><td><code>http://crl.microsoft.com</code><br>(normally optional; sometimes necessary)</td></tr></tbody></table>

#### Additional Considerations

* In the ICA policy settings, ensure the **Virtual channel allow list** is set to **Disabled**. For more information, see the [Citrix documentation](https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/policies/reference/ica-policy-settings/virtual-channel-allow-list-policy-settings).
* If SSL inspection is enabled on your proxy, ensure it doesn't break the TLS handshake.
* If you're behind a **proxy**, make sure `PowerShell` is configured to use it by running the following command:

{% code overflow="wrap" %}

```powershell
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
```

{% endcode %}

#### **Test connectivity**

You can test access using a PowerShell terminal by running the following command:

```powershell
Invoke-WebRequest https://www.powershellgallery.com
```

### Networking <a href="#connectorforcitrixvirtualappsanddesktops-networking" id="connectorforcitrixvirtualappsanddesktops-networking"></a>

The Nexthink Connector for CVAD needs to connect to a Citrix Desktop Delivery controller, Citrix Director and the Nexthink API.

* The Nexthink connector communicates with the Nexthink cloud over TCP port 443.
* Communication between the Nexthink connector server and the Citrix Director uses TCP port 443.
* The connection to the Citrix DDC depends on the Citrix PowerShell SDK and follows your PowerShell configuration. By default, PowerShell communicates over TCP ports 5985 and 5986.

The following figure shows a simplified architecture with a connection between the connector and a delivery controller:

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-6307496aacec633cde33001de2380d243c10d6e8%2Fcvad-connector-architecture.png?alt=media" alt=""><figcaption></figcaption></figure>

### Service account for scheduled tasks <a href="#connectorforcitrixvirtualappsanddesktops-serviceaccountforscheduledtasks" id="connectorforcitrixvirtualappsanddesktops-serviceaccountforscheduledtasks"></a>

The Nexthink Connector for CVAD will run as a scheduled task, one per CVAD environment, and needs to be able to access the Citrix APIs. To limit security concerns, Nexthink recommends using a local user account on the Nexthink connector server or a regular domain user account without any special privileges at the domain level.

The following guide uses a local account on the Nexthink connector server.

1. Log on as an administrator to the server that will run the Nexthink Connector for CVAD.
2. Launch the local users and groups console by running the command `lusrmgr.msc` from the start menu.

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-e33a79105f0d5b3d5de897a63c6ac9bb729684d0%2Fcitr-1678980898.png?alt=media" alt="Run the lusrmgr.msc command" width="306"><figcaption></figcaption></figure>
3. Right-click on the **Users** folder in the **Local Users and Groups (Local)** directory and select **New user…**
4. Create a user account according to your organization's naming conventions. Make a note of the **User name** and **Password** as you will need these later when creating a scheduled task.

   To safeguard the functionality of the connector, select the following options:

   1. **User cannot change password**
   2. **Password never expires**<br>

      <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-bc70b97581f4545c71afe2f5cf02d09ff1b92fb0%2Fcitr-1678981225.png?alt=media" alt="New user options" width="340"><figcaption></figcaption></figure>
5. Click **Create**.
6. Next, open the local group policy editor by executing `gpedit` from the start menu.
7. Navigate to the **Computer Configuration > Windows Settings > Security Settings> Local Policies > User Rights Assignment** and look for the policy called **Log on as a batch Job**.
8. Open the policy and click on **Add User or Group** to add the previously created user to the list.<br>

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-59f156d1c2eac213529b240862e92eb49c95e6e4%2Fcitr-1678981506.png?alt=media" alt="Add user or group" width="374"><figcaption></figcaption></figure>

### Installing the connector <a href="#connectorforcitrixvirtualappsanddesktops-installingtheconnector" id="connectorforcitrixvirtualappsanddesktops-installingtheconnector"></a>

1. [Download the Nexthink Connector for CVAD](#connectorforcitrixvirtualappsanddesktops-prerequisites).
2. Extract the zip file to a folder on your system. Nexthink recommends placing it in the following folder:\
   `C:\program files\Nexthink\Connectors\Citrix`
3. Apply **Modify** permissions for the **Logs** folder for the user account you created earlier.<br>

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-c9b0c0a376dea0265e80ad97108033c0527f927a%2Fcitr-1678982114.png?alt=media" alt="Data properties" width="374"><figcaption></figcaption></figure>

### Nexthink Enrichment API credentials <a href="#connectorforcitrixvirtualappsanddesktops-nexthinkenrichmentapicredentials" id="connectorforcitrixvirtualappsanddesktops-nexthinkenrichmentapicredentials"></a>

The connector for CVAD needs appropriate credentials to connect to the Nexthink Enrichment API. Nexthink stores the credentials safely in the credential store of the local user account you created earlier.

1. Refer to the [API credentials](https://developer.nexthink.com/docs/api/api-credentials) documentation for step-by-step guidance. When you save the API credentials, a new window containing the Client ID and the Secret key appears. Make a note of the information as it will not be accessible once you close the window.

{% hint style="warning" %}
When creating the credentials, ensure that in **Permissions** you have **Enrichment API** selected.
{% endhint %}

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-25527dad3aca35423e85a92c8f2bcd90999443c5%2Fcitr-1679044299.png?alt=media" alt="OAuth client credentials" width="374"><figcaption></figcaption></figure>

2. On the server that will be running the Nexthink Connector for CVAD, open PowerShell under the credentials of the local user you created earlier using the `runas` command in the command line:

```powershell
runas /user:nxt-ctx-connector powershell.exe
```

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-4071de583e2fbe2aee263a36c79648a5fc2a85c0%2Fcitr-1679044505.png?alt=media" alt="runas CLI" width="578"><figcaption></figcaption></figure>

3. In the newly opened PowerShell window, add the API credentials you just created in the Nexthink web interface by running the following command:

{% code overflow="wrap" %}

```powershell
New-StoredCredential -Target "nxt-ctx-connector" -UserName <Client ID> -Password <Secret key> -Persist LocalMachine
```

{% endcode %}

Replace the `<Client ID>` and `<Secret key>` with the values you noted down when creating the API credentials. Make a note of the `TargetName` you used with `-Target` as you will need this value for the configuration file.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-66cc57132cbd7553fbe1391f0bfa2223808152de%2Fcitr-1679044919.png?alt=media" alt="PowerShell window"><figcaption></figcaption></figure>

{% hint style="info" %}
In the `config.json` [configuration file](#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile), these credentials are stored in `"NexthinkAPI"`.

The `TargetName` used with `-Target` is stored in `"WindowsCredentialEntry"`.
{% endhint %}

### Updating the configuration file <a href="#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile" id="connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile"></a>

For the configuration file update, you need the URL of your Nexthink Cloud API instance. The URL pattern looks like this: `instance.api.region.nexthink.cloud`. See the steps listed below for more details.

{% hint style="info" %}
If you do not know your region, reach out to your Nexthink representative to obtain this information.
{% endhint %}

1. Locate the folder where you unzipped the connector for CVAD.
2. Navigate to the **Config** folder and open the `config.json` file using a text editor.
3. Scroll to the `"NexthinkAPI"` section.

<pre class="language-json"><code class="lang-json">{
    "_Info": "This is the JSON based configuration for Citrix Virtual Apps and Desktops connector",
    "Info": {
        "Project": "copla-citrix-onprem-connector",
        "ConfigVersion": "1.1.0"
    },
    "Logging": {
        "LogRetentionDays": 7,
        "LogLevel": "INFO"
    },
    "CitrixEnvironments": [
        {
            "Name": "&#x3C;citrix-environment-name>",
            "CitrixControllerFQDN": "&#x3C;citrix_controller_host>",
            "CitrixDirectorFQDN": "&#x3C;citrix_director_host>",
            "WindowsCredentialEntry": "&#x3C;citrix-user-credentials>"
        },
        {
            "Name": "&#x3C;citrix-environment-name2>",
            "CitrixControllerFQDN": "&#x3C;citrix_controller_host2>",
            "CitrixDirectorFQDN": "&#x3C;citrix_director_host2>",
            "WindowsCredentialEntry": "&#x3C;citrix-user-credentials2>"
        }
    ],
    "NexthinkAPI": {
        "HostFQDN": "&#x3C;nexthink_api_host>",
        "WindowsCredentialEntry": <a data-footnote-ref href="#user-content-fn-1">"nxt-ctx-connector"</a>,
        "RequestBatchSize": "1000"
    }
}
</code></pre>

4. Change the following values under the `"NexthinkAPI"` section:

* Replace the `"HostFQDN"` value with the URL of your Nexthink cloud API instance using the format `instance.api.region.nexthink.cloud` where `instance` and `region` are placeholders.
  * Replace `instance` with the name of the instance
  * Replace `region` with the name of one of the following regions:
    * `us` for the United States
    * `eu` for the European Union
    * `pac` for Asia-Pacific
    * `meta` for the Middle East, Turkey and Africa
  * If needed, you can refer to this URL example: `gwy-eu-west-3-fuji-rest.api.eu.nexthink.cloud`
* Replace the `“WindowsCredentialEntry"` with the `TargetName` of the credentials you noted down from the PowerShell window earlier, for example:\
  `"WindowsCredentialEntry": "nxt-ctx-connector",`

{% hint style="warning" %}
To replace the `"CitrixEnvironments"` values in the configuration file and set up a connection to the CVAD farm, refer to [#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile.1](#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile.1 "mention").
{% endhint %}

## Setting up a connection to the CVAD farm <a href="#connectorforcitrixvirtualappsanddesktops-settingupaconnectiontothecvadfarm" id="connectorforcitrixvirtualappsanddesktops-settingupaconnectiontothecvadfarm"></a>

The previous section described the basic configuration of the Nexthink Connector for CVAD. This section will help you set up a connection to a CVAD environment. Repeat the procedures in this section for every CVAD environment you need to connect to.

### Citrix DDC <a href="#connectorforcitrixvirtualappsanddesktops-citrixdesktopdeliverycontroller-ddc" id="connectorforcitrixvirtualappsanddesktops-citrixdesktopdeliverycontroller-ddc"></a>

Nexthink Connector for CVAD connects to the Citrix Desktop Delivery Controller (DDC) to retrieve data from the Citrix Monitoring API provided by the Citrix Director and the Citrix PowerShell SDK. You need the Citrix DDC name to properly configure the connector.

Make sure the Citrix Director is installed on the DDC and make a note of the fully qualified domain name (FQDN) of the Citrix DDC.

### Creating a read-only Citrix administrator <a href="#connectorforcitrixvirtualappsanddesktops-creatingaread-onlycitrixadministrator" id="connectorforcitrixvirtualappsanddesktops-creatingaread-onlycitrixadministrator"></a>

The Nexthink Connector for CVAD needs read-only access to the Citrix Director API and the Citrix PowerShell SDK. In order to do this, create a domain user account without any special privileges and make a note of the username and password.

1. Launch the Citrix Studio console and start the administrator creation wizard from **Configuration > Administration.**
2. Right-click on **Administration** and select **Create Administrator.**

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-748b2c74fd1ebe4aa6dbac6618e3a56c316e0da8%2Fcitr-1669301721.png?alt=media" alt="Create Administrator" width="374"><figcaption></figcaption></figure>
3. Click the **Browse…** button and select the service account that you previously created.

   * Set the scope to **All** and click **Next** to continue

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-98a2ba5c73f12ec9994be85c299eeab5abb3ae9a%2Fcitr-1669301896.png?alt=media" alt="Scope"><figcaption></figcaption></figure>
4. Select the **Read Only Administrator** role and click **Next** to continue.

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-62d3e63582a44e873cbdfaace494ab04d6f3a291%2Fcitr-1669301951.png?alt=media" alt="Read only administrator"><figcaption></figcaption></figure>
5. Select **Enable administrator** and click **Finish**.

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-a59ee7629430abbe7f01394cac377372fee6869e%2Fcitr-1669302227.png?alt=media" alt="Enable administrator"><figcaption></figcaption></figure>

### Setting up stored credentials <a href="#connectorforcitrixvirtualappsanddesktops-settingupstoredcredentials" id="connectorforcitrixvirtualappsanddesktops-settingupstoredcredentials"></a>

1. On the server that will be running the Nexthink Connector for CVAD, open PowerShell under the credentials of the local user you created earlier using the `runas` command on the command line:

```powershell
 runas /user:nxt-ctx-connector powershell.exe
```

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-4071de583e2fbe2aee263a36c79648a5fc2a85c0%2Fcitr-1679044505.png?alt=media" alt="runas CLI" width="646"><figcaption></figcaption></figure>

2. In the newly opened PowerShell window, add the API credentials you just created in the Nexthink web interface by running the following command:

{% code overflow="wrap" %}

```powershell
New-StoredCredential -Target "nxt-ctx-prod" -UserName <domain\username> -Password -Persist LocalMachine
```

{% endcode %}

Replace the `<domain\username>` and `<password>` with the values you noted down when creating a domain user account with a read-only Citrix administrator.\
\
Make a note of the `TargetName` you used as you will need this value for the configuration file.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-18d8fc9ff5ba47ef0cfcab72995f17b74dee5c78%2Fimage-20230413-133931.png?alt=media" alt="PowerShell window"><figcaption></figcaption></figure>

{% hint style="info" %}
In the `config.json` [configuration file](#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile.1), these credentials are stored in `"CitrixEnvironments"`.

The `TargetName` used with `-Target` is stored in `"WindowsCredentialEntry"`.
{% endhint %}

### Updating the configuration file <a href="#connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile.1" id="connectorforcitrixvirtualappsanddesktops-updatingtheconfigurationfile.1"></a>

Each CVAD environment has its own section in the configuration file. The configuration file that comes with the connector contains an example of how to configure multiple environments. If needed, create a copy of the original `config.json` file for future reference.

1. Locate the folder where you unzipped the connector for CVAD.
2. Navigate to the **Config** folder and open the `config.json` file using a text editor.
3. Scroll to the `"CitrixEnvironments"` section and remove the second item on the list starting with `{ "Name"...` and ending with `"`nxt-ctx-prod`"}`. The code should look similar to the following:

<pre class="language-json"><code class="lang-json">{
    "_Info": "This is the JSON based configuration for Citrix Virtual Apps and Desktops connector",
    "Info": {
        "Project": "copla-citrix-onprem-connector",
        "ConfigVersion": "1.1.0"
    },
    "Logging": {
        "LogRetentionDays": 7,
        "LogLevel": "INFO"
    },
    "CitrixEnvironments": [
        {
            "Name": "&#x3C;citrix-environment-name>",
            "CitrixControllerFQDN": "&#x3C;citrix_controller_host>",
            "CitrixDirectorFQDN": "&#x3C;citrix_director_host>",
            "WindowsCredentialEntry": <a data-footnote-ref href="#user-content-fn-1">"nxt-ctx-prod"</a>
        }
    ],
    "NexthinkAPI": {
        "HostFQDN": "&#x3C;nexthink_api_host>",
        "WindowsCredentialEntry": "nxt-ctx-connector",
        "RequestBatchSize": "1000"
    }
}
</code></pre>

Change the following values in the `"CitrixEnvironments"` section:

* Replace `<citrix-environment-name>` with the name of your environment.
* Replace `<citrix-controller-host>` with the name of the Citrix DDC.
* Replace `<citrix_director_host>` with the name of the Citrix Director.
* Replace `"nxt-ctx-prod"` with the `TargetName` of the stored credentials you created earlier in PowerShell.
* Make a note of the identifier as you will need it later.

### Testing the connector <a href="#connectorforcitrixvirtualappsanddesktops-testingtheconnector" id="connectorforcitrixvirtualappsanddesktops-testingtheconnector"></a>

1. On the server that will be running the Nexthink Connector for CVAD, open PowerShell under the credentials of the local user you created earlier using the `runas` command on the command line:

```powershell
runas /user:nxt-ctx-connector powershell.exe
```

2. Change to the directory where you installed the connector, for example:\
   `cd 'C:\Program Files\Nexthink\Connectors\Citrix\'`
3. Run the `Citrix-Connector-Auto-Updater.ps1` script with the following command:

```powershell
.\Citrix-Connector-Auto-Updater.ps1
```

4. Run the `Citrix-Connector-Runner.ps1` script with the following command:

```powershell
.\Citrix-Connector-Runner.ps1 -CitrixEnvironment <Citrix PROD>
```

Replace `<Citrix PROD>` with the name you chose for the environment.

The expected output for both scripts is `0`, similar to the following figure:

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-a11cfc37154e9534b903d9d2be22181f48883c28%2Fimage.png?alt=media" alt="Script output"><figcaption></figcaption></figure>

Correct execution should provide a log such as the following:

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-99b6224671d86f1f0597b3deadc9f2ef6e395288%2Fimage.png?alt=media" alt="Script execution log"><figcaption></figcaption></figure>

After executing the command, the PowerShell window closes and a folder with the name you chose for the connection should appear. In the folder, you will find a log file with the result of the test.

### Setting up a scheduled task <a href="#connectorforcitrixvirtualappsanddesktops-settingupascheduledtask" id="connectorforcitrixvirtualappsanddesktops-settingupascheduledtask"></a>

1. Open the task scheduler and select **Create task…**

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-e4cdd40df98d68e566780ee02b2ecd8127017101%2Fcitr-1669383499.png?alt=media" alt="Create a task" width="306"><figcaption></figcaption></figure>
2. Name the task and change the user to the service account that you previously created in the **General** tab. Select **Run whether user is logged on or not**. Click **OK**.

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-781c005287fa11ef72510be74aad6c9c76b376c4%2Fcitr-1679385360.png?alt=media" alt="Citrix PROD connector properties" width="544"><figcaption></figcaption></figure>
3. Switch to the **Triggers** tab.
4. Under **Advanced settings > Repeat tasks every**, select an adequate frequency. Click **OK**.

{% hint style="info" %}
Nexthink recommends setting the frequency to a low value, such as 1 minute, to enable a fine granularity for data collection. However, if this value is too low for your infrastructure, you can go up to even a 1-hour granularity.
{% endhint %}

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-ec49cc2e845d1230fd015ff9b4117ac4ffd1ce03%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

5. Switch to the **Actions** tab and create a new action.
6. Paste the full path of the `Citrix-Connector-Auto-Updater.ps1` script into the **Add arguments (optional)** field, including the environment name, for example `-ExecutionPolicy Bypass -File "C:\Program Files\Nexthink\Connectors\Citrix\Citrix-Connector-Auto-Updater.ps1"`.\
   Start in the folder containing the script, for example `C:\Program Files\Nexthink\Connectors\Citrix` Click **OK**.

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-b39ad1dcc25eb3e105661c61b283fe920d140462%2Fcitr-1670319737.png?alt=media" alt="Edit action" width="476"><figcaption></figcaption></figure>
7. A window will prompt you to enter the password of the service account. Click **OK**.<br>

   <figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-b34805f1e6808fd75ff8560bfcb6f7f97958b03b%2Fcitr-1679387044.png?alt=media" alt="Confirm credentials" width="306"><figcaption></figcaption></figure>
8. Schedule another one for `Citrix-Connector-Runner.ps1` script into the **Add arguments (optional)** field, including the environment name, for example `-ExecutionPolicy Bypass -File "C:\Program Files\Nexthink\Connectors\Citrix\Citrix-Connector-Runner.ps1" -CitrixEnvironment "Citrix PROD"`. Start in the folder containing the script, for example `C:\Program Files\Nexthink\Connectors\Citrix` .Click **OK**.

***

RELATED TOPIC

* [API Credentials](https://developer.nexthink.com/docs/api/api-credentials)

[^1]: This value must match the parameter for `New-StoredCredential -Target`.
