This script can be used to prepare layers right before they are finalised.
To install and configure App Layering 4.x see: http://www.jgspiers.com/installing-configuring-unidesk-4/
To create and update an OS Layer see: http://www.jgspiers.com/create-update-os-layer-unidesk-4/
To create and update an Application Layer and create Elastic Layers see: http://www.jgspiers.com/application-layers-elastic-layering-unidesk-4/
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):