Automating the Citrix App Layer

If your daily job has anything to do with virtual workspaces, you definitely have heard something about app layering. App layering is seen as the replacement for the ‘old’ application virtualization solutions like Microsoft App-V and VMware ThinApp.
While app layering is a good solution for most of the usual issues that come with running many applications on the same machines, it still takes a lot of time to create all those layers.
So together with automation-aficionado Chris Twiest we asked ourselves the question:
Is it possible to automate app layer creation?

This blog will focus on the automation of creating app layers with Citrix App Layering, while Chris Twiest focused on doing the same with VMware App Volumes, the result of which you can find here. This blog is also a precursor to our presentation at the Expert 2 Expert Virtualization Conference in Athens (link).

EDIT Dec 19th 2018: Click here for a YouTube video of the presentation.

App Layering players:
There are currently three main players in the app layering space:
VMware App Volumes (formerly CloudVolumes)
Citrix App Layering (formerly UniDesk)
LiquidWare FlexApp

I am not going to make a detailed comparison of the three. Bas van Kaam already made an excellent blog about it, which definitely is worth a read.

Why are we doing this and how did we get there:
The main goal of this automation-challenge was to see if it actually can be done and not to create a production-ready, fast and, most important of all, vendor-supported solution. This last thing currently is not even possible since neither App Layering, App Volumes nor FlexApp currently offer a SDK of some sort to ‘talk’ to the app layering solution. So we needed to resort to other methods.

Instead of Chris Twiest, who reverse-engineered the App Volumes management page in a very interesting way, I actually had it pretty easy. Ryan Butler already did most of the work for me by creating a PowerShell SDK for Citrix App Layering (link).

The automation process:
So after the usual automation hassle (scripting, testing, bug fixing, rinse and repeat) I ended up with the script below. Although the actual app layer creation was pretty easy, I spent a lot of time installing the application and finalizing the image.
Where the competing products have a dedicated sequencer, Citrix App Layering creates one during app layer creation from the specified OS layer. Since you don’t know the hostname or the IP address of the machine, I used PowerCLI to grab that information from VMware vSphere. If you are using another hypervisor, you would need to edit that part of the script. Luckily, the name of the virtual machine in the hypervisor will have the app layer name in its own display name so you can filter based on that.

When I have the hostname and IP, I can use invoke-command to install the application and run the ‘Shutdown for finalize’ batch file. After that, the script will actually finalize the layer.

The variables and the installation:
Before I will get to the script, I will run through all the variables that you would need to edit to make it work in your environment. I have divided this into two kinds of parameters:
Values specific for your environment (probably only edited during setup)
Values specific for the application layer that you want to create (edited for each app layer)

To get the script running you would need the following things:
– Citrix App Layering appliance
– Citrix App Layering connector to your hypervisor
– OS layer of Windows 7, 8.x or 10 with the firewall disabled and PS remoting enabled (Enable-PSRemoting –Force)
– Management server with PowerCLI installed (assuming you are using vSphere)
– Ryan Butler’s Citrix App Layering PowerShell SDK somewhere on a file-share (optional, it will try to download it first)
– Application installation file somewhere on a file-share (single file installations only currently!)
– Application silent installation parameters

Copy the script to your management server and run through the following variables:

Static variables:
Hostname/IP/FQDN of your VMware vCenter server.
Hostname/IP/FQDN of your Citrix App Layering appliance.
Username of an App Layering administrator.
Password of the same App Layering administrator.
Location of the (downloaded) Citrix App Layering PowerShell SDK.
Username of an administrator in the OS layer/sequencer.
Password of the OS layer administrator.
Name of the folder that will be used as temporary location for the application installer.
Drive letter that will be used to connect to the local disk of the sequencer.
Name of the hypervisor connector in Citrix App Layering.
Name of the OS layer that you would like to use.

App layer variables:
Name of the app layer that you would like to create.
Description of the application that you are installing.
Location of application installer file.
Name of application installer file. (MSI or EXE, if MSI then misexec.exe /I command will automatically be added)
Silent installation parameters for the application.

After filling out all these variables, you are ready to run the script. Now keep in mind that Citrix App Layering is not the fastest solution in the world, so the script will run for a while. I am also using a lot of ‘Start-Sleep’-commands that I don’t really like and might break the script when your environment is too slow.
When I find the time, I will look into refining this by waiting for specific results. But for now: feel free to improve it where needed. 😉

The actual script:

DISCLAIMER: Once again: I’m in no way an expert PowerShell scripter, so it might not be the most efficient code, but it gets the job done. And, of course, feel free to use it/alter it/publish it as your own.

 53,646 total views,  1 views today

4 thoughts on “Automating the Citrix App Layer

  1. Travis Adams

    Just to point out something. On the Citrix Applayering connection script, if you have any reserved characters that is in your console password, make sure to use proper XML escape chars to get around it. otherwise the connect-alsession will fail.

    1. Travis Adams

      as i saw this i found a handy solution 🙂

      put that on the line before the convert $ALPassword to secure string (line 49) and that should fix the issue.
      i had a password with an & in it… this converts that to a &
      in theory this should work with any other XML escape chars.


Leave a Reply

Your email address will not be published. Required fields are marked *