Citrix App Layering Preparation Script

This script can be used to prepare layers right before they are finalised.

To install and configure App Layering 4.x see:

To create and update an OS Layer see:

To create and update an Application Layer and create Elastic Layers see:

Script author: George Spiers – @JGSpiers

With thanks to Trentent Tye for allowing me to include his Ghost Device removal script.

Tested working on OS version: Windows Server 2016, Windows Server 2012 R2, Windows Server 2008 R2, Windows 10, Windows 7.

Description: This scripts runs a number of tasks to clean out temporary folders, clear out Event Log entries, remove ghost devices from Device Manager, and run NGEN native image regenerations before shutting down the image in preparation for layer finalisation. If running this script on Windows 8.1+ or Windows Server 2012 R2+ there is an extra firewall check that looks to see if any of the firewall profiles are disabled and if so, asks if you want to enable them. When patching within an OS Layer version my patching software requires a number of ports to be open and it is easier just to temporarily disable the firewall until patching is done. The problem was remembering to enable the firewall again!

Note: You should run this script each time you create an OS Layer version, Application Layer/version and Platform Layer/version.

Instructions: You must run this script as an administrator. You must also set the PowerShell Execution Policy to atleast “RemoteSigned” or “Unrestricted”.

Download (click below):

App Layering Preparation Script (320 downloads)


  • ciprian

    August 21, 2017

    download link it’s not working ..yet

  • ciprian

    August 21, 2017

    working now.

  • Rotem Sfarad

    August 23, 2017

    sound very helpful thanks buddy ;).

  • Nick Panaccio

    August 23, 2017

    Out of curiosity, is there any reason you’re asking for the full path of the script on line 52 instead of using something like the following?

    $ScriptPath = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)

    Either way, thank you for this.

    • George Spiers

      August 23, 2017

      No reason at all! Your suggestion is one less input so I’ll stick it in the script. Thanks

  • Pingback: App Layering – App Layers, Image Templates, and Publishing – Carl Stalhood

  • Pingback: Detailed Change Log – Carl Stalhood

  • Ci

    September 14, 2017

    i ran the script, but sometimes i got error on ngen still ran in background…i have to choose shutdown fro finalized exe provide by unidesk. But i did notice that if i just unidesk exe , my PVS will become non genius

  • Pingback: App Layering – OS Layer and Platform Layer – Carl Stalhood

Leave a Reply