Adding App-V Publishing Information to a XenDesktop Site with PowerShell

Adding Microsoft App-V publishing information to a XenDesktop or XenApp 7.x site is very easy via the Citrix Studio UI, but what if you want to automate this process? Of course, you’ll need to reach for PowerShell.

AppV publishing information in XenDesktop

What may not be widely known is that you can add additional App-V publishing configuration to a XenDesktop site beyond what you see in the UI. This allows you to set publishing information per delivery group. Useful for complex XenDesktop sites such as multi-tenant environments.

Creating the App-V publishing information with PowerShell is a multi step process. You’ll need to create the publishing information with New-CtxAppVServer and then apply the configuration with New-BrokerMachineConfiguration.

Applying this in practice however may ultimately require testing the App-V management and publishing servers and ensuring that the configuration does not already exist before adding it.

So to do that, I’ve written a function that will take the App-V Management and Publishing servers as parameters, ensure that they test OK and check that the configuration does not already exist before importing the configuration into the site.

This function is fairly basic and while it does do some error checking, it could probably go a little further to ensure the configuration is applied successfully.

Please ensure that you test thoroughly before using in a production environment. Comments or feedback on bugs, better ways to do things or additional steps is welcome.

Note – a very big thanks to David Wagner at Citrix (and team) for assisting with working out how to write the App-V publishing information that you see in the Studio UI. This is done by applying the description “Created with Studio” to the publishing configuration (presumably only the first configuration that you apply with that description).

Implementing a Workaround for issue affecting the App-V Client in KB2984972

A recent security update for the Remote Desktop Connection client in Windows 7 and Windows Server 2008 R2 has affected both the Microsoft App-V 4.6 and 5.0 client.

After you install this security update, virtualized applications in Microsoft Application Virtualization (App-V) versions 4.5, 4.6, and 5.0 may experience problems loading. When the problem occurs, you may receive an error message that resembles the following:

Launching MyApp 100%

Note In this error message, MyApp represents the name of the App-V application.

Depending on the scenario, the virtualized app may stop responding after it starts, or the app may not start at all.

This issue was reported in the forums as well and seems to affect a number of applications.

Microsoft have updated the KB article for the security update to provide a workaround (see the known issues section). Another KB article is on the way, targeted more directly at the App-V client. No word at the time of writing as to a more permanent fix.

The workaround requires implementing a Registry change to the App-V client to add an additional item to the global events that are excluded by the virtualization layer in App-V. Full details are in the KB article and I recommend reading that before continue with this article.

Implementing the Workaround

There’s a few ways that you could implement the fix – Group Policy Preferences, scripting etc. You will need to pay attention to the entires in the HKLM\SOFTWARE\Microsoft\AppV\Subsystem\ObjExclusions (for App-V 5.0) or HKLM\SOFTWARE\Microsoft\SoftGrid\4.5\SystemGuard\ObjExclusions (for App-V 4.6) as each entry requires a unique value name – you don’t want to overwrite an existing entry.

Here’s the ObjExclusions key on an App-V 5.0 client:

AppV Client ObjExclusions registry key

AppV Client ObjExclusions registry key

Most environments will have the default entries (92 for App-V 5.0, 94 for App-V 4.6). For customised environments you would need to ensure that a unique value is used (perhaps above 93).

Group Policy Preferences

Group Policy Preferences is the most straight forward method of implementing the workaround. Most environments are already managing the App-V client with Group Policy, so adding a Preference item in the same GPO make sense.

Add a new GPP Registry item with the necessary Registry configuration. Ensure the value name is unique (any number above the existing values). This could be a high number (e.g. 256) to ensure there is no clash with an existing value.

Adding TermSrvReadyEvent via Group Policy Preferences

I recommend enabling Item-level targeting to ensure the value is added to the right machines.

Enabling Item Level Targeting

For example, only apply the update if the HKLM\SOFTWARE\Microsoft\AppV\Subsystem\ObjExclusions key actually exists. This ensures the value is only added once the App-V client is installed.

Adding a Key Exists match to Item Level Targeting

PowerShell

PowerShell makes it easy to generate a unique number by first counting the exiting entries. Here’s some code that will count the existing entires and use that count as the unique number Note the (Default) entry is also returned, so I can be confident that I’m using a value that is one higher than the existing entries.