Integrate Application Virtualization with Citrix Provisioning Services

Attention: This blog post was originally written in Swedish but has been translated with Google.

A while ago I was in a project where we wanted to use Microsoft Application Virtualization (App-V) 5.1 and Citrix Provisioning Services (PVS) 7.8. This is still a relatively unexplored area although the possibility has existed for some time. During the course of the project, we encountered two problem areas; boot menu and loading times of AppV packages for end users. Citrix, in consultation with Microsoft, has published an integration overview. This contains good information about the actual functions of AppV, but not how to put the whole thing together. The idea of the project was to keep as clean a PVS Master as possible, free of applications to be able to easily update and maintain applications without creating new vDisks.

Redirected start menu and loading times of applications

The best way to create a start menu in Citrix XenApp 7 is still to use the redirected start menu. One of the big problems with the App-V Management Infrastructure is that it needs to have write permissions on the start menu in order to populate the shortcuts. Another problem is that users need to wait for the App-V packages to be loaded into the session before they can be started. In an environment where it is estimated to run approximately 400 applications, it is unreasonable to wait for all these applications to be loaded, before the users can start working and start the applications.


In order to avoid the waiting time of loading applications via App-V, we looked at "caching" applications directly on our PVS Targets. At startup, we put in a startup script. The problem with this is that each application needs to be loaded at startup of all targets. Five AppV applications took about 15 minutes to load on startup, which means 400 applications would take… a long time.
The solution was to run the same startup script on our Masters. Since we know that we would need to make at least one vDisk per month to maintain the environment through Windows Updates, this means that applications are added, changed or removed successively on reboot without any manual intervention. We run the below script on both Master and Targets, which causes the applications that are not already cached directly on the vDisk to be loaded on reboot. When you make a new vDisk, the applications that are not already on the Master are loaded.

<#
    .SYNOPSIS
        Refreshes all App-V Packages on a master and target
    .DESCRIPTION
        Removes all packages with a deprecated path. Then adds all new app-v packages and updates those who have been updated since last cycle
    .NOTES
        Name: CTX-UAT-XA-C-AppV_PublishedStartup.ps1
        Author: Vikingur Saemundsson, Xenit AB
        Designer: Måns Hurtigh, Xenit AB
        Date Created: 2016-06-21
        Version History:
            2016-06-21
            - Initial Creation
#>
[cmdletbinding()]
Param(
[String]$AppVDir = "$Env:CTXFILEROOT\App-V\Published"
)
Begin{
}
Process{
    #Remove all app-v packages where the path is no longer valid.
    Get-AppvClientPackage | ForEach-Object{
        If(-not(Test-Path $_.Path)){
            $_ | Stop-AppvClientPackage | Unpublish-AppvClientPackage -Global | Remove-AppvClientPackage | Out-File "C:\Xenit\AppvRemove.log"
        }
    }
    #Re-publish all packages where there is a newer version
    $AllPackages = Get-AppvClientPackage
    Get-ChildItem -Path $AppVDir -Filter "*.appv" -Recurse -Force | Add-AppvClientPackage | ForEach-Object{
        $exists = $false
        $thisPkg = $_
        $AllPackages | Where-Object{$_.PackageId -eq $thisPkg.PackageId} | ForEach-Object{
            If($ThisPkg.VersionId -ne $_.VersionId){
                $_ | Stop-AppvClientPackage | Unpublish-AppvClientPackage -Global | Remove-AppvClientPackage | Out-File "C:\Xenit\AppvChange.log"
            }
            Else{$exists = $true}
        }
        If(-not($exists)){
            $thisPkg | Add-AppvClientPackage | Mount-AppvClientPackage | Publish-AppvClientPackage -Global | Out-File "C:\Xenit\AppvPublish.log"
        }
    }
}

Since all packages are placed directly in the Master and in turn the vDisk that is published, this means that you can point your shortcuts from your redirected start menu to C:\Programdata\AppV<AppID><VersionID>*.exe. When the applications are already stored locally, users will have a much better user experience. Basically as close to locally installed applications as possible.

Feel free to contact me if you have problems or want to discuss App-V integrations in your Citrix environment.