Powershell Script to launch one or more Published Applications from Citrix StoreFront 1912 CU1 (1912.0.1000)

by Stan Czerno September 26, 2020 09:53 CST

I have updated my script for testing "Direct to Citrix Storefront" or "Citrix Gateway to Storefront" to work with Citrix StoreFront 1912 CU1 (1912.0.1000).

I have tested the script with Internet Explorer 11 and Citrix Workspace 1912 and 2006 on Windows 10 x64.

The script attempts to closely resemble what an actual user would do to launch an Application or Desktop via Storefront:

  • Opening Internet Explorer.
  • Navigates to the Receiver for Web site or Citrix Gateway portal.
  • Entering a Username and Password.
  • Clicking on the Log on button.
  • Clicking on the Published Application(s) or Desktop.
  • Logging off the StoreFront site.

You can use this script to confirm your most important Published Application(s) launch correctly and in a timely manner.

You can use this Script to verify that each of your servers is responding correctly, as well. To do this you will need to Publish an Application from each server. For example, you could publish Task Manager (taskmgr.exe), from each server, and name it something like "Server 1 Task Manager", "Server 2 Task Manager", etc.

The script has the ability to send an email along with the log file when an error is encountered. The email body will contain the error message(s) and the log file which basically documents each step and where the error occurred.

Script Requirements:

  • Citrix Workspace installed in the default location.
  • Must be launched from an Elevated Administrator console of PowerShell x86. The 64 Bit PowerShell will not work since the script is using Citrix Workspace, which is 32 bit, to verify a launch and logoff the session.
  • No other XenApp/XenDesktop sessions should be connected/running before running the script.
  • The SiteURL parameter should be part of the Intranet Zone (or Internet Zone at Medium-Low security) in order to be able to download AND launch the ICA file without interaction. This can be done through a GPO or locally.
  • Requires Citrix StoreFront 1912 or Citrix Gateway, version NS13.0 64.35.nc or greater. Be sure the Citrix Gateway theme is set to RfWebUI or a custom theme based off of RfWebUI.
  • Requires autoLaunchDesktop to be set to false. (Manage Receiver for Web Sites -> Configure -> Client Interface Settings -> uncheck Auto Launch Desktop
  • Requires the pluginAssistant to be set to false. https://support.citrix.com/article/CTX209283
  • Currently works for desktops or already subscribed (favorites) apps and desktops only.
  • You can auto subscribe users to apps by setting "KEYWORDS:Auto" in the published app's description or make sure the apps have been subscribed to manually.
  • In order for the script to interact with the ICO, the script modifies the required changes in the registry:
    • x64: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\ICA Client\CCM
    • x86: HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ICA Client\CCM
      • AllowLiveMonitoring REG_DWORD 1
      • AllowSimulationAPI REG_DWORD 1

Create some Apps to use with the Script:

The first thing you should do is to publish the Application (or Desktop) and assign it to your test user.

If you want to test each server, then you need to publish an Application (or Desktop) from each server and assign it to your test user. What I mean by that is; if you have five servers, you will need to publish the App or Desktop five times, one for each server. In this scenario I am not testing load balancing, I am testing to make sure each server launches the application correctly and within an acceptable time frame.

I chose Task Manager for my testing, but it can be any Application, such as Command Prompt. The more lightweight the Application the better, you do not want to put extra strain on your servers.

You can also use a Published Desktop but Desktops are more resource intensive and take a little longer to launch since it initializes the Explorer shell. If you choose a Desktop you may need to extend the wait times, especially for the Log off command by adding -TimeToWaitForLogoff to the command line. By default this is set to 30 seconds and a Desktop may not logoff within 30 seconds. Overall, I have noticed that using a Desktop can be problematic. It is not so much an issue with the Server but with CDViewer on the client. So I recommend using Task Manager or Command Prompt for the test.

Subscribe to Apps:
The Apps need to be visible in order for the Script to launch them. You will need to log in to Storefront, as the Test User, manually and subscribed to the Apps. Alternatively, you can auto subscribe the Apps by setting "KEYWORDS:Auto" in the published app's description.

Schedule the Task:
My Scheduled Task's Action looks like this:

Program/Script:
%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe

Add arguments: 
-executionpolicy bypass -file c:\CitrixScript\SFLauncher1912.ps1 -SiteURL "https://citrix.domain.com" -UserName "domain\TestUser" -Password "TestUserPassword" -smtpServer "smtp.server.domain" -emailFrom "XenAppMon@domain.com" -emailTo "email@domain.com" -LogFilePath C:\CitrixScript -LogFileName SFLauncher.log "App1" "App2"

Start in: 
C:\CitrixScript

Security options:
The user account that runs the scheduled task needs to be an administrator on the computer so PowerShell can be elevated. This does not need to be the same as the Test User used in the script to connect to XenApp/XenDesktop.
Be sure to use the options "Run whether user is logged on or not" and "Run with highest privileges".

Command Line Notes:
The Application(s) to be launched need to be at the end of the command line, separated by a space, like this: "App Server1" "App Server2"

Testing from a Command Prompt:
If you want to test before Scheduling, open a Command Prompt as an Administrator (right click and choose "Run as Administrator")
To test the script, here is a sample command line:
%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file c:\CitrixScript\SFLauncher1912.ps1 -SiteURL "https://citrix.domain.com" -UserName "domaain\TestUser" -Password "TestUserPassword" -smtpServer "smtp.server.domain" -emailFrom "XenAppMon@domain.com" -emailTo "email@domain.com" -LogFilePath C:\CitrixScript -LogFileName SFLauncher.log "App Server1" "App Server2"

Link to Script: 

SFLauncher1912.ps1 (58.08 kb)

  

Tags: , ,

Catergories: Citrix | Receiver | Storefront | XenApp | XenDesktop | Powershell

Comments (2) -

mraxa
December 4, 2020 05:16 CST

HI,
this only works in 32-bit Windows 10/7. When this script runs on any x64 system then it throws the following error. Any thing needs to be done for this?

New-Object : Retrieving the COM class factory for component with CLSID {238F6F83-B8B4-11CF-8771-00A024541EE3} failed
due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\temp\SFLauncher1912.ps1:196 char:12
+     $ica = New-Object -ComObject 'Citrix.ICAClient'
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (Smile [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

Stan Czerno
December 4, 2020 16:19 CST

As I stated in the Script Requirements: "Must be launched from an Elevated Administrator console of *PowerShell x86*. The 64 Bit PowerShell will not work since the script is using Citrix Workspace, which is 32 bit, to verify a launch and logoff the session."

Comments are closed