Citrix Workspace Command Line



Citrix Workspace app Commandline Tool March 8, 2021 March 16, 2021 Citrix Citrix This software application is provided to you “as is” with no representations, warranties or conditions of any kind.

A few weeks ago I wrote a blog about scripting Citrix PVS. In this blog I will show the most popular commands for Citrix XenServer so that you can use them in your Automation Workflow. Because as always; AUTOMATE EVERYTHING! Citrix XenServer is Linux based so in the command line you can use Linux commands like ls-l or mount. But it also has its own command lines starting with XE. This blog will include those command lines and the PowerShell commands. To get PowerShell working with Citrix XenServer you need to download and install the XenServer SDK from here under the Development Components section

  • You can also use the Citrix Receiver Commandline Helper Toolto help you to build the exact command line syntax. This tool has not yet been renamed to Citrix Workspace app Commandline Helper Tool. It is difficult for me to tell you exactly which command line switches (= parameters) you should use. This all depends on your environment.
  • Using the SelfService.exe on the command line The SelfService.exe is part of Citrix Workspace app. This executable aggregates (retrieves) a user's resources. With resources I refer to published applications and published desktops.

To install the PowerShell SDK you need to copy the PowerShell Module folder from the zip to $env:windirsystem32WindowsPowerShellv1.0Modules To enable the module use the following command: Import-Module XenServerPSModule

Connect to XenServer

PowerShell:

Command line

Citrix

Open a SSH connection with Putty or use the console tab in XenCenter.

New VM

PowerShell:

From Windows 2016 64Bit Template:

PowerShell:

Command Line:

xe vm-install template=Windows Server 2016 (64-bit) new-name-label=NEWVM

Delete VM

PowerShell:

Command Line:

Xe vm-list name-label=VMNAME

Copy VMUUID

xe vm-destroy uuid=VMUUID

Change VM Specs

PowerShell:

Enlarge RAM en vCPU

Dicrease vCPU and RAM

Citrix

Command Line

Change RAM

Xe vm-list name-label=VMNAME

Copy VMUUID

xe vm-memory-limits-set uuid=VMUUID static-min=2GiB static-max=2GiB dynamic-min=2GiB dynamic-max=2GiB

Add more vCPU’s

Xe vm-list name-label=VMNAME

Copy VMUUID

xe vm-param-set uuid=VMUUID VCPUs-max=4 VCPUs-at-startup=4

Remove vCPU’s

Xe vm-list name-label=VMNAME

Copy VMUUID

xe vm-param-set uuid=VMUUID VCPUs-at-startup=2

xe vm-param-set uuid=VMUUID VCPUs-max=2

Add Disk to VM

PowerShell:

Command Line

xe vm-list name-label=VMNAME

Copy VMUUID

xe sr-list name-label=”Local storage”

Copy Storage UUID

xe vdi-create sr-uuid=STORAGEUUID name-label=Disk01 type=user virtual-size=20GiB

Output is DISKUUI

xe vbd-create vm-uuid=VMUUID device=1 vdi-uuid=DISKUUID bootable=false mode=RW type=Disk

Change VM Description

PowerShell:

Command line:

Xe vm-list name-label=VMNAME

Copy VMUUID

xe vm-param-set uuid=VMUUID name-description=”DISCRIPTION”

Export VM

PowerShell:

Command Line:

Mkdir /mnt/Export

mount -t cifs //server/share -o username=UserName,password=myPassword /mnt/export

xe vm-export vm=VMNAME filename=/mnt/export/Export.xva

Create Snapshot

PowerShell:

Command Line:

xe vm-snapshot vm=VMName new-name-label=SNAPSHOTNAME

Delete Snapshot

PowerShell

Citrix Workspace Command Line

Command Line:

xe snapshot-list name-label=SNAPSHOTNAME

Copy Snapshot UUID

xe vm-destroy uuid=SNAPSHOTUUID

Start VM

PowerShell:

Citrix workspace command line

Command Line:

xe vm-start vm=VMName

Stop VM

PowerShell:

Command Line:

xe vm-shutdown vm=VMName

Reboot VM

PowerShell:

Command Line:

xe vm-reboot vm=VMName

Get VM List

PowerShell:

Command Line:

xe vm-list

Get Template List

PowerShell:

Command Line:

xe template-list

Get Snapshot List

PowerShell:

Command Line:

xe snapshot-list

I hope this was informative. For questions or comments you can always give a reaction in the comment section or contact me:

downloadWhy can't I download this file?

Assuming the system is set up to communicate with the same provider or store for all users, the SSP model is to:

  1. Start up.

  2. Authenticate to the store.

  3. Enumerate the resources the user is entitled to access.

  4. Create shortcuts for the resources the user has subscribed to or that the administrator has auto-subscribed them to. The store may be set as mandatory, in which case all resources are subscribed. If Receiver is communicating with a Web Interface Services site then all resources are automatically subscribed.

Store interaction

By default, there is a delay of about two minutes before the store is contacted. You can override this by setting the following registry keys and adjusting for Wow6432Node as appropriate:

Key

Notes

REG_SZ HKLMSOFTWARECitrixDazzleInitialRefreshMinMs

Set to 1.
Setting is in milliseconds.
0 returns to the default.

REG_SZ HKLMSOFTWARECitrixDazzleInitialRefreshMaxMs

Set to 1.

Shortcuts

For any subscribed application, SSP builds a Start menu shortcut that launches an HDX session for that application when the user selects it. These shortcuts persist after the user logs off from the aggregation tier. If the user selects the shortcut without being logged on, they are prompted for credentials before the application launches. There is an exception to this: if the published application is tagged with a prefer keyword that has a value matching an existing local shortcut, no hosted shortcut is created. This is to save the overhead of a hosted launch where a local one might suffice. For further details, see http://support.citrix.com/proddocs/topic/receiver-windows-40/receiver-windows-config-app-delivery.html

SSP mimics a local install by building an .exe file that causes the application to start remotely when the file is run. Shortcuts are created for the application and an Add/Remove Software entry is also built. When SSP builds a shortcut, it builds it to a small stub application in a file %appdata%CitrixSelfServiceapp-name-with-spaces-removed.exe for each resource. These files allow SSP to create a fake 'install' record for Add/Remove Software. Running these .exe files causes the application to launch. This may be the simplest launch option for scripting: look for the relevant .exe file under the user’s profile area and execute it.

If you want to drive SSP directly for launch instead of through an .exe stub, look at the keys under HKCUSoftwareMicrosoftWindowsCurrentVersionUninstall. There will be keys in there named farm-name@@server-farm-name.app-friendly-name. In these keys you'll find a LaunchString value that shows the relevant parameters. These parameters are user-independent and can therefore be cloned from a reference user to a general case.
These launchstrings will be of the form

Citrix Workspace Command Line Download

You can copy and reuse these parameters without interpretation. This may be off-putting if the aim is to try and build a control for these independently. It is not necessary though to understand resources at this abstract level if more control is required.

Additional command-line arguments can follow the above format or be passed to the .exe stubs.

For both the stub and the direct launch methods, SSP will take care of authentication and interaction with the Web Interface or StoreFront.
Alternatively to -launch, -qlaunch, which has a simpler syntax, can be used. Please see below for details.

Cache file for resource details

A cache file is created per provider when SSP exits. This file records the last enumeration details and allows SSP to start up quickly. The name of the cache file is decorated with the internal store name.

Running the command selfservice.exe –init –ipoll –exit starts SSP, performs a refresh (interactive poll) from the current provider, and forces a clean exit. The cache file is then created in the %LOCALAPPDATA%citrixselfservice directory.

The cache file contains information about each resource, including all the information needed for a launch.
The launch command line contains:

If you look in a cache file (an example name might be storeservi-ee876897_cache.xml) you will see that it has a <resource> entry per application or desktop.

To construct a launch command line from this file, use the following details:

STOREIDThe name of the file (do not include _cache.xml)
RESOURCEID Contents of <internalName>
ICALAUNCHURLContents of <icaLaunchUrl>

Citrix Workspace Command Line Tool

The cache file will contain some LaunchCommandLine entries, but only for subscribed or prelaunch resources.

There is also a dump.xml file in the same location with similar content. This file is intended for external consumption (unlike the cache file). It contains some but not all LaunchCommandLines.

Other useful SSP parameters

Note that where multiple parameters are supplied, SelfService.exe executes them in order.

Parameter

Description and notes

SelfService.exe –logoff

Log off current user.

SelfService.exe –rmPrograms

Clean up shortcuts and stub programs for current user.

SelfService.exe –reconnectapps

Reconnect to any existing sessions the user has. By default happens at launch time and app refresh time.

SelfService.exe –disconnectapps

Disconnect any current HDX sessions.

SelfService.exe –createproviderStoreName StoreURL

Create a provider.
For example: SelfService.exe –init –createprovider Go https://testserver.net/Citrix/MyStore/discovery

SelfService.exe –deleteproviderbyname StoreName

Remove a provider.

SelfService.exe –deleteproviderandlocalappsbyname StoreName

Remove a provider.

SelfService.exe –poll Contact the server to refresh application details.
SelfService.exe –ipoll Contact the server to refresh application details as in –poll, but if no authentication context is available, prompt the user for credentials.
SelfService.exe –deletePasswordsRemove any stored passwords.
SelfService.exe –exitExit from SelfService.exe.
SelfService.exe –qlaunch “appname” See Note 1.

Launch applications.
Note: This parameter can be customized with <appname> <argument>. Publish the application with “%*” in command line parameter. Example: To launch published application named 'IE11' opening http://www.citrix.com, use:
selfservice.exe -qlaunch IE11 http://www.citrix.com

SelfService.exe –qlogon
See Note 1.

Reconnect any existing apps for current user.

SelfService.exe –fastterminate
See Note 1.

Log off the current user and leaves their applications connected.

SelfService.exe –terminate
See Note 1.

Disconnect applications for all users on endpoint.

SelfService.exe –terminateuser “user_name”
See Note 1.

Disconnect applications for a specific user.

SelfService.exe –logoffSessionsLog off all the active sessions for the current user
Note: This flag is available only in Receiver for Windows 4.12 and later versions.

Note 1: These parameters are available only in Receiver 4.2 and later versions.

Additional Resources

Citrix Documentation - Configure and install Citrix Receiver for Windows using Command Line parameters.