Citrix Virtual Apps and Desktops service

SDKs and APIs

Citrix Virtual Apps and Desktops Remote PowerShell SDK

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 Manage user interfaces.

How this SDK differs from the SDK for customer-managed deployments

In a Citrix Virtual Apps and Desktops deployment that is installed and managed by customer administrators, those administrators run cmdlets and scripts in a site containing VDAs and Delivery Controllers within a common domain structure. In contrast, the Citrix Virtual Apps and Desktops service splits the VDAs and Controllers into a resource location and the control plane, respectively. This split means that the original Citrix Virtual Apps and Desktops PowerShell SDK does not work in a Citrix Virtual Apps and Desktops service environment. It cannot cross the secure boundary from the resource location to the control plane.

The solution is the Citrix Virtual Apps and Desktops Remote PowerShell SDK. When running in the resource location, the Remote PowerShell SDK accesses the control plane as if it is local. This provides the same functionality as a single Citrix Virtual Apps and Desktops site. There is only the lowest non-visible communication layer, enhanced to work either in a single local site or in the cloud environment. The cmdlets are the same, and most existing scripts remain unchanged.

The Get-XdAuthentication cmdlet provides the authorization to cross the secure resource location to control plane boundary. By default, Get-XdAuthentication prompts users for CAS credentials, and must be done once per PowerShell session. Alternatively, the user can define an authentication profile using an API access Secure Client, created in the Citrix Cloud console. In both cases, the security information persists for use in subsequent PowerShell SDK calls. If this cmdlet is not explicitly run, it is called by the first PowerShell SDK cmdlet.

Install and use the Remote PowerShell SDK

Requirements:

Note:

Do not install the Remote PowerShell SDK on a Citrix Cloud Connector machine. It can be installed on any domain-joined machine within the same resource location.

Citrix recommends that you do not run this SDK’s cmdlets on Cloud Connectors. The SDK’s operation does not involve the Cloud Connectors.

If you also have an on-premises Citrix Virtual Apps and Desktops deployment (in addition to the Virtual Apps and Desktops service deployment), do not install the Remote PowerShell SDK on an on-premises Delivery Controller machine.

  • Ensure that PowerShell 3.0 or later is available on the machine.
  • The SDK installer downloads and installs .NET Framework 4.8 if it (or a later supported version) is not already installed.
  • If the machine already has the Citrix Virtual Apps and Desktops SDK installed, remove that SDK (from Windows Programs and Features) before installing the Remote PowerShell SDK.

To install the Remote PowerShell SDK:

  1. From the download page, download the Virtual Apps and Desktops Remote PowerShell SDK.
  2. Install and run the SDK.

Installation logs are created in %TEMP%\CitrixLogs\CitrixPoshSdk. Logs can help resolve installation issues.

Run the SDK on a domain-joined computer within that resource location:

  • Open a PowerShell command prompt. You do not need to run as an administrator.
  • Add the Citrix snap-ins: asnp citrix.*.
  • You can explicitly authenticate by using the Get-XdAuthentication cmdlet. Or, run your first Citrix Virtual Apps and Desktops PowerShell SDK command, which prompts you for the same authentication as Get-XdAuthentication.
  • To bypass the authentication prompt, you can use the Set-XdCredentials cmdlet to create a default authentication profile, using a Secure Client created in the Citrix Cloud console.
  • Continue running PowerShell SDK cmdlets or PowerShell SDK automation scripts. See an example.

To uninstall the Remote PowerShell SDK, from the Windows feature for removing or changing programs, select Citrix Virtual Apps and Desktops Remote PowerShell SDK. Right-click and select Uninstall. Follow the dialog.

Example activities

Common activities include setting up machine catalogs, applications, and users. A sample script is shown below.

    $users = "xd.local\Domain Users"

    $TSVDACatalogName = "TSVDA"

    $TSVDADGName = "TSVDA"

    $TSVDAMachineName = "xd\ds-tsvda2"

    #Create TSVDA Catalog

    $brokerUsers = New-BrokerUser -Name $users

    $catalog = New-BrokerCatalog -Name $TSVDACatalogName -AllocationType "Random" -Description $TSVDACatalogName -PersistUserChanges "OnLocal" -ProvisioningType "Manual" -SessionSupport "MultiSession" -MachinesArePhysical $true

    #Add TSVDA Machine to Catalog

    $BrokeredMachine = New-BrokerMachine -MachineName $TSVDAMachineName -CatalogUid $catalog.uid

    #Create new desktops & applications delivery group

    $dg = New-BrokerDesktopGroup -Name $TSVDADGName -PublishedName $TSVDADGName -DesktopKind "Shared" -SessionSupport "MultiSession" -DeliveryType DesktopsAndApps -Description $TSVDADGName

    #Create notepad application

    New-BrokerApplication -ApplicationType HostedOnDesktop -Name "Notepad" -CommandLineExecutable "notepad.exe" -DesktopGroup $dg

    #Assign users to desktops and applications

    New-BrokerEntitlementPolicyRule -Name $TSVDADGName -DesktopGroupUid $dg.Uid -IncludedUsers $brokerUsers -description $TSVDADGName

    New-BrokerAccessPolicyRule -Name $TSVDADGName -IncludedUserFilterEnabled $true -IncludedUsers $brokerUsers -DesktopGroupUid $dg.Uid -AllowedProtocols @("HDX","RDP")

    New-BrokerAppEntitlementPolicyRule -Name $TSVDADGName -DesktopGroupUid $dg.Uid -IncludedUsers $brokerUsers -description $TSVDADGName

    #Add machine to delivery group

    Add-BrokerMachine -MachineName $TSVDAMachineName -DesktopGroup $dg

Support and limitations

The following Citrix Virtual Apps and Desktops PowerShell snap-ins are supported in this release:

  • Broker
  • Active Directory (AD) Identity
  • Machine creation
  • Configuration
  • Configuration logging
  • Host
  • Delegated administration
  • Analytics

For details about cmdlets in those snap-ins, see Citrix Virtual Apps and Desktops SDK.

After authentication, remote access remains valid in the current PowerShell session for 24 hours. After that time, you must enter your credentials.

The Remote PowerShell SDK must be run on a computer within the resource location.

The following cmdlets are disabled in remote operations to maintain the integrity and security of the Citrix Cloud control plane.

Citrix.ADIdentity.Admin.V2:

  • Copy-AcctIdentityPool
  • Get-AcctDBConnection
  • Get-AcctDBSchema
  • Get-AcctDBVersionChangeScript
  • Get-AcctInstalledDBVersion
  • Remove-AcctServiceMetadata
  • Reset-AcctServiceGroupMembership
  • Set-AcctDBConnection
  • Set-AcctServiceMetadata
  • Test-AcctDBConnection

Citrix.Analytics.Admin.V1:

  • Get-AnalyticsDBConnection
  • Get-AnalyticsDBSchema
  • Get-AnalyticsDBVersionChangeScript
  • Get-AnalyticsInstalledDBVersion
  • Import-AnalyticsDataDefinition
  • Remove-AnalyticsServiceMetadata
  • Reset-AnalyticsServiceGroupMembership
  • Set-AnalyticsDBConnection
  • Set-AnalyticsServiceMetadata
  • Set-AnalyticsSite
  • Set-AnalyticsDBConnection

Citrix.DelegatedAdmin.Admin.V1:

  • Add-AdminRight
  • Get-AdminDBConnection
  • Get-AdminDBSchema
  • Get-AdminDBVersionChangeScript
  • Get-AdminInstalledDBVersion
  • Import-AdminRoleConfiguration
  • New-AdminAdministrator
  • Remove-AdminAdministrator
  • Remove-AdminAdministratorMetadata
  • Remove-AdminRight
  • Remove-AdminServiceMetadata
  • Reset-AdminServiceGroupMembership
  • Set-AdminAdministrator
  • Set-AdminAdministratorMetadata
  • Set-AdminDBConnection
  • Set-AdminServiceMetadata
  • Test-AdminDBConnection

Citrix.Broker.Admin.V2:

  • Get-BrokerDBConnection
  • Get-BrokerDBSchema
  • Get-BrokerDBVersionChangeScript
  • Get-BrokerInstalledDBVersion
  • Get-BrokerLease
  • New-BrokerMachineConfiguration
  • Remove-BrokerControllerMetadata
  • Remove-BrokerLease
  • Remove-BrokerLeaseMetadata
  • Remove-BrokerMachineConfigurationMetadata
  • Remove-BrokerMachineConfiguration
  • Remove-BrokerSiteMetadata
  • Remove-BrokerUserFromApplication
  • Reset-BrokerLicensingConnection
  • Reset-BrokerServiceGroupMembership
  • Set-BrokerControllerMetadata
  • Set-BrokerDBConnection
  • Set-BrokerLeaseMetadata
  • Set-BrokerMachineConfiguration
  • Set-BrokerMachineConfigurationMetadata
  • Set-BrokerSiteMetadata
  • Test-BrokerDBConnection
  • Test-BrokerLicenseServer
  • Update-BrokerBrokerLocalLeaseCache

Citrix.Configuration.Admin.V2:

  • Export-ConfigFeatureTable
  • Get-ConfigDBConnection
  • Get-ConfigDBSchema
  • Get-ConfigDBVersionChangeScript
  • Get-ConfigInstalledDBVersion
  • Get-ConfigServiceGroup
  • Import-ConfigFeatureTable
  • Register-ConfigServiceInstance
  • Remove-ConfigRegisteredServiceInstanceMetadata
  • Remove-ConfigServiceGroup
  • Remove-ConfigServiceGroupMetadata
  • Remove-ConfigServiceMetadata
  • Remove-ConfigSiteMetadata
  • Reset-ConfigServiceGroupMembership
  • Set-ConfigDBConnection
  • Set-ConfigRegisteredServiceInstance
  • Set-ConfigRegisteredServiceInstanceMetadata
  • Set-ConfigServiceGroupMetadata
  • Set-ConfigServiceMetadata
  • Set-ConfigSite
  • Set-ConfigSiteMetadata
  • Test-ConfigDBConnection
  • Unregister-ConfigRegisteredServiceInstance

Citrix.Host.Admin.V2:

  • Get-HypDBConnection
  • Get-HypDBSchema
  • Get-HypDBVersionChangeScript
  • Get-HypInstalledDBVersion
  • Remove-HypServiceMetadata
  • Reset-HypServiceGroupMembership
  • Set-HypDBConnection
  • Set-HypServiceMetadata
  • Test-HypDBConnection

Citrix.ConfigurationLogging.Admin.V1:

  • Get-LogDBConnection
  • Get-LogDBSchema
  • Get-LogDBVersionChangeScript
  • Get-LogInstalledDBVersion
  • Remove-LogOperation
  • Remove-LogServiceMetadata
  • Remove-LogSiteMetadata
  • Reset-LogDataStore
  • Reset-LogServiceGroupMembership
  • Set-LogDBConnection
  • Set-LogServiceMetadata
  • Set-LogSite
  • Set-LogSiteMetadata
  • Test-LogDBConnection

Citrix.MachineCreation.Admin.V2:

  • Get-ProvDBConnection
  • Get-ProvDBSchema
  • Get-ProvDBVersionChangeScript
  • Get-ProvInstalledDBVersion
  • Get-ProvServiceConfigurationData
  • Remove-ProvServiceConfigurationData
  • Remove-ProvServiceMetadata
  • Reset-ProvServiceGroupMembership
  • Set-ProvDBConnection
  • Set-ProvServiceConfigurationData
  • Set-ProvServiceMetadata
  • Test-ProvDBConnection

Citrix.EnvTest.Admin.V1:

  • Get-EnvTestDBConnection
  • Get-EnvTestDBSchema
  • Get-EnvTestDBVersionChangeScript
  • Get-EnvTestInstalledDBVersion
  • Remove-EnvTestServiceMetadata
  • Reset-EnvTestServiceGroupMembership
  • Set-EnvTestDBConnection
  • Set-EnvTestServiceMetadata
  • Test-EnvTestDBConnection

Citrix.Monitor.Admin.V1:

  • Get-MonitorConfiguration
  • Get-MonitorDBConnection
  • Get-MonitorDBSchema
  • Get-MonitorDBVersionChangeScript
  • Get-MonitorDataStore
  • Get-MonitorDataStore
  • Get-MonitorInstalledDBVersion
  • Remove-MonitorServiceMetadata
  • Reset-MonitorDataStore
  • Reset-MonitorServiceGroupMembership
  • Set-MonitorConfiguration
  • Set-MonitorDBConnection
  • Set-MonitorServiceMetadata
  • Test-MonitorDBConnection

Citrix.Storefront.Admin.V1:

  • Build-SfCluster
  • Get-SfClusters
  • Get-SfDBConnection
  • Get-SfDBSchema
  • Get-SfDBVersionChangeScript
  • Get-SfInstalledDBVersion

Citrix Virtual Apps and Desktops service discovery module for App-V packages and servers

The Citrix Virtual Apps and Desktops service can deliver applications contained in App-V packages to your endpoints using either of the following methods:

  • Single admin management method (accessing packages from a network share)
  • Dual admin management method (accessing packages from a Microsoft App-V Management Server)

The process of registering App-V packages, Microsoft App-V Management, and Publishing Servers with the Application Library using the Citrix Virtual Apps and Desktops service differs slightly from registering packages using an on-premises deployment. However, the process of assigning applications to users and launching them on a user’s endpoint is identical.

The service management console in Citrix Cloud cannot view files in a resource location. Also, it cannot directly discover App-V packages or Microsoft App-V servers in your infrastructure. The discovery module provides functions that discover App-V package information in your on-premises infrastructure and uploads the package information to your Virtual Apps and Desktops service. Package information includes App-V packages, Microsoft App-V servers, and the apps that the packages contain.

The discovery module uses the Virtual Apps and Desktops Remote PowerShell SDK. It can discover package information from either a network share or a Microsoft App-V Management Server. You use the discovery module on a machine in your resource location.

Prerequisites for using the discovery module:

  • Verify that PowerShell 3.0 or later is available on the machine.
  • Verify that the Citrix Virtual Apps and Desktops Remote PowerShell SDK is installed on the machine.
  • Verify that you have access to the network share containing the App-V packages.
  • Verify that you have access to the server where the Citrix Cloud Connectors are installed and the Microsoft App-V Management Server is hosted.

Add App-V packages to the Application Library in Citrix Cloud

The following procedure is valid for adding App-V packages from network shares (single admin management) and adding all published App-V packages from the Microsoft App-V Management Server (dual admin management). With the dual admin management method, you must manage the added App-V packages just as you do when using the single admin management method.

  1. Download the discovery module from the Citrix Virtual Apps and Desktops Service downloads page https://www.citrix.com/downloads/citrix-cloud/product-software/xenapp-and-xendesktop-service.html. Extract the zip file Citrix.Cloud.AppLibrary.Admin.v1.psm1 to a convenient folder.

    Note:

    This file is also provided on the Citrix Virtual Apps and Desktops ISO in Support\Tools\Scripts. You can copy it locally or reference it directly from the CD drive.

  2. Verify that the Virtual Apps and Desktops Remote PowerShell SDK is installed on your machine

  3. Navigate to the folder containing the discovery module. In the PowerShell window, type the full path of the folder containing the discovery module and then press Enter.

  4. Import the discovery module with the command Import-Module.\Citrix.Cloud.AppLibrary.Admin.v1.psm1.

  5. Add the App-V packages to the Application Library in Citrix Cloud using either of the following methods.

    • To add App-V packages from a network share, run the PowerShell cmdlet: Import-AppVPackageToCloud.

      For example: Import-AppVPackageToCloud –PackagePath \\AppVSrv\share\Notepad++.appv

      For cmdlet help, type Get-Help Import-AppVPackageToCloud.

    • To add App-V packages from a Microsoft App-V Management Server, run the PowerShell cmdlet: Import-AppVPackagesFromManagementServerToCloud

      For example: Import-AppVPackagesFromManagementServerToCloud –ManagementSrvFQDN AppVMngSrv.domain.local

      For cmdlet help, type Get-Help Import-AppVPackagesFromManagementServerToCloud

      This command imports all published App-V packages from the Microsoft App-V Management Server to Citrix Cloud.

      After adding the App-V packages to Citrix Cloud, you must manage them as you do using the single admin management method.

  6. Sign in to Citrix Cloud. Select the target customer. After the script runs successfully, the App-V packages are added to the Application Library in Citrix Cloud.

Remove an App-V package from the Application Library in Citrix Cloud

To remove an App-V package from the Application Library in Citrix Cloud, see Remove an App-V package from the Application Library in on-premises deployments.

High-level PowerShell functions

The module contains the following high-level functions that you can call from your own PowerShell script:

  • Import-AppVPackageToCloud -PackagePath <Full UNC path to App-V package>

    Discovers and uploads to the Citrix Virtual Apps and Desktops service all the information necessary to publish applications from a single App-V Package.

  • Import-AppVPackagesFromManagementServerToCloud -ManagementSrvFQDN <FQDN of a Microsoft App-V Management Server>

    Discovers the UNC paths of packages published by the Management Server and calls Import-AppVPackageToCloud for each one in turn.

    Packages discovered in this way are loaded to the Citrix Virtual Apps and Desktops Service using the single admin management method. The Citrix Virtual Apps and Desktops Service cannot deliver packages using the dual admin management method.

  • Import-AppVDualAdminToCloud -ManagementSrvUrl <URL of a Microsoft App-V Management Server> -PublishingServerUrl <URL of a Microsoft App-V Publishing Server>

    Discovers Microsoft App-V Management and Publishing Servers and imports the content to the Application Library. This cmdlet imports all the packages managed using Microsoft App-V Management Server and related information. Servers can be added and removed through PowerShell.

    This cmdlet adds App-V packages in dual admin mode. Only App-V packages that are published on the Microsoft App-V Management Server, and which have AD groups added, are imported. If you make changes to the Microsoft App-V Management Server, rerun this cmdlet to synchronize the Application Library with the Microsoft App-V Management Server.

  • Remove-AppVServerFromCloud -ManagementSrvUrl <URL of a Microsoft App-V Management Server> -PublishingServerUrl <URL of a Microsoft App-V Publishing Server>

    Removes the Microsoft App-V Management and Publishing Servers added to Application Library.

    This cmdlet removes the specified Microsoft App-V Management and Publishing Servers, plus all the associated App-V packages.

Run the discovery module for App-V packages and servers on a domain-joined computer within that resource location. Follow the guidance in Install and use the Remote PowerShell SDK to get started. Continue running PowerShell cmdlets or scripts. See the following examples.

Example activities

Import the Virtual Apps and Desktops service App-V package discovery module.

import-module "D:\Support\Tools\Scripts\Citrix.Cloud.AppLibrary.Admin.v1.psm1"

Loop through the App-V Package store directory and upload each package.

Get-ChildItem -Path "\\FileServer.domain.net\App-V Packages" -Filter *.appv |
Foreach-Object{
    Import-AppVPackageToCloud -PackagePath $_.FullName
}

Discover and upload packages registered with a Microsoft App-V management server.

Import-AppVPackagesFromManagementServerToCloud -ManagementSrvFQDN AppVManagementServer.domain.net

Discover Microsoft App-V Management and Publishing Servers and add the configuration to the Application Library. This also imports all the packages managed by the Microsoft App-V Management Server in dual admin mode.

Import-AppVDualAdminCloud -ManagementSrvUrl http://AppVManagementServer.domain.net –PublishingServerUrl http://AppVManagementServer.domain.net:8001

Read PowerShell help documentation included in the module.

Get-Help Import-AppVPackageToCloud

Limitations

  • You cannot discover App-V packages on your resource location infrastructure directly from the service management console in Citrix Cloud.
  • The service management console in Citrix Cloud does not have a live connection to the Microsoft App-V Management server. Changes to Packages and other configuration in the Microsoft App-V Management server are not reflected in the service management console until Import-AppVDualAdminCloud is rerun. This differs from the on-premises package discovery behavior).

Monitor Service OData API

In addition to using the Monitor functions to display historical data, you can query data using the Monitor Service’s API. Use the API to:

  • Analyze historical trends for planning
  • Perform detailed troubleshooting of connection and machine failures
  • Extract information for feeding into other tools and processes; for example, using Microsoft Excel’s PowerPivot tables to display the data in different ways
  • Build a custom user interface on top of the data that the API provides

For details, see Monitor Service OData API. To access the Monitor Service API, see Access Monitor Service data using the OData v4 endpoint in Citrix Cloud.

Citrix Virtual Apps and Desktops service APIs

The Virtual Apps and Desktops service APIs are available at https://developer.cloud.com/citrixworkspace/virtual-apps-and-desktops.

Disclaimer

This software / sample code is provided to you “AS IS” with no representations, warranties, or conditions of any kind. You may use, modify, and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software / sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software / sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software / sample code. In no event should the software / code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE / SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any claims arising from your use, modification, or distribution of the code.