Working with UE-V Template Catalog Updates via Command Line

When managing clients using the Microsoft User Environment Virtualization (UE-V) agent, a common practice is to have a central Settings Template Catalog.  This allow for efficient distribution of common Settings Location Templates, either custom made with the UE-V Generator or downloaded from the TechNet Gallery, to UE-V clients across the organization. By default, the UE-V agent will retrieve updates from the Settings Template Catalog via a Scheduled Task which runs at 3:30AM every day:

The Scheduled Task launches the following executable (assuming 64-bit platform, obviously):

    C:\Program Files\Microsoft User Experience Virtualization\Agent\x64\ApplySettingsTemplateCatalog.exe

In order to force the update, you can either execute the program directly, or force the Scheduled Task to run using the following command:

Schtasks /Run /TN “Microsoft\UE-V\Template Auto Update”

In the User Experience Virtualization 1.0 release, this will result in an immediate sync with the Settings Template Catalog.

With the release of MDOP 2013 and UE-V 1.0 SP1 however, Microsoft opted to change things up a bit by randomizing the run time for the Settings Template Catalog update.  The update is now randomized over the course of an hour. Unfortunately, instead of randomizing the time the Scheduled Task is set to run, it is the ApplySettingsTemplateCatalog.exe itself that randomizes…

Scheduled Task for Catalog Updates is now randomized

The Template Auto Update task checks the settings template catalog for new, updated, or removed templates. This task only runs if the SettingsTemplateCatalog is configured. The Template Auto Update task runs the ApplySettingsCatalog.exe file, which is located in the UE-V Agent install directory and with UE-V SP1 has been changed to randomize the update over a one hour period.

This leaves a couple options: running the Template Auto Update task and either hoping you get lucky or waiting up to an hour, or looking for another means of pulling in or purging the template.  Fortunately, this can easily be done using a few cmdlets in the built-in PowerShell module.

Let’s say I have a custom template for an application named “My Custom UE-V Template” (MyTemplate.xml) that I’ve dropped out in the catalog, but I don’t want to wait until early morning to have it sync up and I’m far too impatient to wait on ApplySettingsTemplateCatalog.exe to decide when it wants to randomly pull down the template.  Maybe I ran it already, but when I check in PowerShell using a command such as Get-UevTemplate | where {$_.ApplicationName -like “*template*”} it’s not showing up:

Rather than waiting, I’ll just use the Register-UevTemplate cmdlet to pull it in right away. I could use the Get-UevConfiguration cmdlet to refresh my memory on where the SettingsTemplateCatalogPath is…but I’d much rather just pull it dynamically, wouldn’t you?  So let’s grab the path from the config* and pass it to the Register-UevTemplate cmdlet along with the name of our XML file:

Register-UevTemplate -LiteralPath ((Get-UevConfiguration | select-object -expand Values)[4] + ‘\MyTemplate.xml’)

Did it work?

It did…but be aware that if you set up the Settings Template Catalog with the minimum permissions Microsoft provides, you will receive an Access Denied error attempting to access the catalog location.

So now we have instant gratification despite the UE-V SP1 randomization feature.

Of course, the same holds true for removing the template; if I remove it from the catalog, it will automatically unregister at the next scheduled sync.  But I may not want to wait, so let’s use the Unregister-UevTemplate cmdlet to make quick work of it:

Get-UevTemplate | where {$_.ApplicationName -like “*template*”} | Unregister-UevTemplate

Just like that…

…our work is done.

Now obviously if we’re just testing UE-V templates it’s not likely we’ll be dropping them in the same catalog all agents are pointing to in production.  What this more realistically gives us is a means of forcing clients to update right away in an urgent situation where the normal update cycle isn’t sufficient (for instance, a sudden problem with a core application not playing well with its template).  Hopefully this will both give you a means of quickly addressing template issues and help you understand a little more about how UE-V works from a centralized management standpoint.

*The Get-UevConfiguration cmdlet returns data in a little different way than expected for someone just starting out with PowerShell.  The command provided grabs the indexed value corresponding to the SettingsTemplateCatalogPath key.

 

email

Written by , Posted .