Restricting Operating Systems in App-V 5

When restricting operating systems in App-V 5, App-V 5 sees Windows 10 x64 and Windows Server 2016 as the same operating system. Here we present an alternative method that uses App-V 5 scripting to filter your operating system restrictions for App-V 5.

Restricting Operating Systems in App-V 5

I’ve recently been working on an App-V 5 application where two variants are required – one is for Windows 10 x64 and one is for Windows Server 2016 (Citrix virtual desktop sessions).

To reduce administration, my current client wanted both App-V variants to be published to the same Active Directory group so that users could float between their standard desktops and Citrix sessions seamlessly. My first thoughts were that I could simply set the ‘target OS’ condition for each variant….until I stumbled upon this:

Windows 10 Server 16 Target OS

In App-V 5 we can’t distinguish between Windows 10 x64 and Windows Server 2016 by using the ‘Target OS’ functionality. So instead I wrote the following AddPackage script to add similar logic in the Deployment.config file:

<MachineScripts>
<AddPackage>
<Path>powershell.exe</Path>
<Arguments>-ExecutionPolicy ByPass -WindowStyle Hidden -Command  "&amp; { if ([int](Get-CimInstance Win32_OperatingSystem | Select-Object -Expand ProductType) -eq 3) { Exit 0 } else { Exit 1 } }"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

This line of PowerShell merely checks to see if the current machine is a server platform (a ProductType of 3) or not (Work Station = 1, Domain Controller = 2, Server = 3). If it is a server platform the script will return 0 and AddPackage will run successfully . If it is not a server package the script will fail (return a non-zero value of 1) and roll back. This will of course be silent to the end-user.

It doesn’t go into the granularity of checking the specific operating system, but it serves our purpose well since we are only packaging for Windows 10 and Server 2016.