This post was co-authored by Aavisek Choudhury, Enterprise Architect and General Manager for Digital Workspace Services at HCL.
Automation is an essential tool in large-scale virtual apps and desktop deployments and their ongoing management. It reduces costs, minimizes human error, and speeds up time to value for organizations.
I sat down with Aavisek Choudhury, Enterprise Architect for Digital Workspace Services at HCL, to talk about how to get started with Citrix Cloud automation using PowerShell SDK effectively and easily, and we identified some “quick tips” that will help you kick-start your automation journey.
Existing PowerShell and a New Citrix Cloud Deployment
Using PowerShell for a typical on-prem Citrix Virtual Apps and Desktop deployment isn’t new, and many scripts have been created to take full advantage of this capability. However, the scripts written for on-prem environments tend to create hiccups during a Citrix Cloud deployment. In a typical on-prem Citrix Virtual Apps and Desktop setup, all the recourses are part of a large domain, and there are no real boundaries to PowerShell’s reach. So, when the command is triggered from any domain-joined machine, the scope is for the entire Citrix Virtual Apps and Desktops site.
However, in Citrix Cloud, the resources are part of the resource location, and management is part of the control plane, which are separated by secure boundaries of scope. So, to run the remote PowerShell commands, the commands need to be adapted for Citrix Cloud SDK. This change requires some foundational difference in the SDK used for this functionality.
Getting Started with Citrix Cloud and PowerShell SDK
High-level instructions are available in Citrix’s product documentation, but here is some guidance that will help you get going. The first step in setting up the automation platform is to create a connection with the Citrix Cloud environment. Here’s how:
1) Log in to the Citrix Cloud console with your Citrix Cloud credentials.
2) Navigate to Identity and Access Management.
3) Go to API access tab, Secure Clients, then “Name your Secure Client” and click on Create Client.
4) Once you’ve created the client, the ID and secret can be downloaded in a CSV file for future use. This secret will be used in subsequent steps. If you are working on an Azure-based DevOps automation environment, the best practice is to store the credential in an Azure Key Vault for security. In case of local automation setup, you can save it in a local drive, as well.
5) Once the key is saved, you need to configure the system where the automation environment is set up for the remote PowerShell SDK operations. This is the platform where all the PowerShell automation takes place. To set up the environment, download the correct SDK. You can download the SDK here.
6) This SDK should be run on a domain-joined workstation. The pre-requisites are covered in our product documentation.
7) There are multiple installation methods mentioned in the documentation, but to keep it simple, install directly from the downloaded executable.
After using the wizard, the installation is complete and you’ll see a prompt for confirmation:
Setting up the SDK for Automation
After you’ve installed the SDK on a domain-joined Windows machine, create the connection with Citrix Cloud and start your first PowerShell command.
1) To set up the connection with Citrix Cloud environment, use the Client Secret created in the above steps. The command to use in PowerShell would look like:
Set-XDCredentials -CustomerId “citrixdemo” -SecureClientFile “c:\temp\secureclient.csv” -ProfileType CloudAPI –StoreAs “default”
2) You can use the following PowerShell commands to list the PowerShell Citrix Cloud profiles stored in the computer locally:
Get-XDCredentials -ListProfiles
3) If there are multiple profiles stored to connect to different Citrix cloud instances, this is how it would look:
4) After you run the below command, connect to the Citrix Cloud instance, which is stored in CloudConnect1 (in our case). Once this connection is established, all the Citrix Remote SDK commands can be executed seamlessly.
Get-XDAuthentication –ProfileName “CloudConnect1”
5) There are multiple Citrix Virtual Apps and Desktops PowerShell modules available, which gets updated with new capabilities regularly. Make sure to bookmark the Citrix Developer Docs page for the latest updates.
6) To check the various PowerShell modules available, you can use the following command to list the unique PowerShell modules available:
Get-Module Citrix.* -ListAvailable | Select-Object Name -Unique
7) You can also check for all the commands within each module. For example, to find out all the commands within the module Citrix.Broker.Commands, use the following PowerShell command:
Get-Command -Module Citrix.Broker.Commands
That’s how to get started with automation for Citrix Cloud using Remote PowerShell SDK.
What Now?
The Remote PowerShell SDK automates complex and repetitive tasks. It provides the mechanism to set up and manage the Citrix Virtual Apps and Desktops service environment, without using the user interfaces. Citrix has all the PowerShell modules to complete most of the operations in the Citrix Virtual Apps and Desktops service. Combined with DevOps tools like Jenkins and Azure DevOps, you can achieve Infra as Code model.
Get the description of each Cmdlet in Citrix’s developer documentation. For example:
- Detailed description of each Cmdlet is provided in the Citrix Virtual Apps and Desktops service SDK. Bookmark this page!
- The supported modules are listed in the support and limitations section, which also lists the Cmdlets that are disabled in this SDK.
Automation helps to drastically reduce operation time, enabling you to reduce costs and avoid human error, and it’s simple to get started with automation for Citrix Cloud. It can also provide a great platform for partners to develop new IPs and use them to provide immediate benefits to customers.
Learn how you can accelerate your digital transformation and automation with Citrix and HCL LibreSpace to deliver a secure, future-proof desktop virtualization solution.