How to execute remote Powershell scripts in Citrix VAD environments

Case #

You have a Citrix VAD (Virtual Apps and Desktops) environment on-premise, a Citrix Virtual Apps and Desktops service environment on the Citrix Cloud or a hybrid solution. In either case, you need to manage your Citrix components via Powershell cmdlets instead of using Citrix Studio.

Solution #

In order to utilize Powershell to manage your Citrix VAD components, you will need to make use of the Citrix Powershell snap-ins, as part of the Citrix VAD Powershell SDK.

Citrix Virtual Apps and Desktops Cloud service #

In the case of Citrix Virtual Apps and Desktops Cloud service, you should utilize the Citrix Virtual Apps and Desktops Remote PowerShell SDK. This SDK provides the mechanism to set up and manage the Citrix Virtual Apps and Desktops service environment without using the Studio user interface and is applicable only to the Citrix Virtual Apps and Desktops Cloud service, i.e. it is not applicable to on-premise VAD environments. The Citrix Virtual Apps and Desktops Remote PowerShell SDK can be downloaded from https://www.citrix.com/downloads/citrix-cloud/product-software/xenapp-and-xendesktop-service.html. Documentation about the SDK cmdlets can be found at: https://developer-docs.citrix.com/projects/citrix-virtual-apps-desktops-service-sdk/en/latest/.

Citrix Virtual Apps and Desktops on-premise #

For on-premise deployments, you will first need to install all Powershell snap-ins on the local / management machines where you will be running your Powershell cmdlets from and ensure that Powershell remoting is enabled for the target Citrix machines. After installing the snap-ins (they come in form of .msi files included in the Citrix Virtual Apps and Desktops iso/binaries in x64\Citrix Desktop Delivery Controller folder) you should execute the following command:

asnp Citrix*
asnp Citrix.*
or 
Add-PSSnapin Citrix*
Add-PSSnapin Citrix.*

After all Citrix SDK snap-ins are installed, run the Citrix PowerShell commands by using the "AdminAddress" parameter. You need to configure this parameter so that your machine can contact the DDC to execute the command and fetch results. Below is a sample command:

Get-BrokerSite -AdminAddress "HostName of the Delivery Controller"

The latest Citrix Virtual Apps and Desktops product software binaries can be downloaded from https://www.citrix.com/downloads/citrix-virtual-apps-and-desktops/product-software/ (Citrix account required). Full cmdlet documentation for the Citrix Virtual Apps and Desktops SDK on-premise can be found at: https://developer-docs.citrix.com/projects/citrix-virtual-apps-desktops-sdk/en/latest/.

General note:

Powershell snap-ins are not supported in Powershell core. Sames stands for other .NET components which are fundamental to the Citrix FMA architecture, such as WCF components, which are not supported in .NET core (on which Powershell core is based). Therefore the latest version of Powershell for Windows should be used instead. You can use REST API from PowerShell Core instead (if you are Citrix Cloud customer): https://developer.cloud.com/virtual-apps-and-desktops/.

Sources #

https://docs.citrix.com/en-us/citrix-virtual-apps-desktops-service/sdk-api.html

https://developer-docs.citrix.com/projects/citrix-virtual-apps-desktops-sdk/en/latest/

https://support.citrix.com/article/CTX222326

Powered by BetterDocs