The Challenge: 

The APP-V 5.0 client consists of an .exe calling the appropriate MSI (32 or 64 bit) and  prerequisites the Microsoft Visual C++ 2010 Redistributable and the Microsoft Visual C++ 2005 SP1 Redistributable. Because of the .exe file you cannot simply deploy the APP-V 5.0 client by a GPO. Because of the Visual C++ prerequisites, just deploying the separate MSIs won’t work. To complicate things, the APP-V 5.0 client also needs PowerShell 3.0 which is part of the Windows Management Framework 3.0. On Windows 7 this needs to be installed separately because Windows 7 default comes with PowerShell 2.0. This version of Windows Management Framework can be download from the Microsoft site as a Windows Update (.msu) file. Because of issues with the Microsoft server products, this update has been retracted from the Windows Update Service and thus needs to be deployed using another method.

The solution:

In order to install APP-V on a machine we need to check the following:

app-v5

 

 

 

 

 

 

 

 

 

 

 

Luckily this isn’t very complicated to do with PowerShell! First thing we’re going to do is test which version of Powershell is installed.  This can be done in Powershell by looking at:

$psversiontable.psversion.Major

This will give the version of the installed Powershell, if it’s lower than version 3, we’ll need to install the Windows Management Framework. However this comes in two flavors: 32 bit and 64 bit. How to find out which one to install?  Well, again this is easy to do in Powershell:

$os=Get-WmiObject  Win32_OperatingSystem  | select OSArchitecture

This will query WMI and return the OS architecture in the variable $os. After this we can call the correct version of the WMF 3.0 update. Once the Windows Management Framework has been installed, it won’t become active until a reboot but we’re not going to force that (your users probably won’t like a sudden reboot just after logging in 🙂 )

If the PowerShell level is 3 or higher we’re ready to proceed to the next step, check if APP-V 5.0 is already installed.  This can be done by checking the registry. The location of the registry settings in APP-V 5.0 has changed from previous versions. Older versions stored their settings in  HKLM\SOFTWARE\Microsoft\Softgrid\Client.  APP-V 5.0 has been totally rewritten and the location of the settings also has changed to HKLM\SOFTWARE\Microsoft\APPVclient. So the easiest check to see if APP-V 5.0 has been installed is to check if that registry path exists. In PowerShell we can do this with:

$isthere=test-path “HKLM:SOFTWARE\Microsoft\APPVclient”

If the variable $isthere is true then APP-V 5.0 is already installed, if it isn’t then it needs to be installed by starting the following:

start-process -FilePath “\\servershare\appv_clients5SP1\APPV_CLIENT_SETUP.exe” -ArgumentList “/MUOPTIN=1  ACCEPTEULA=1 /q /norestart” -Wait

This will silently run the client setup executable with some arguments: MUOPTIN=1 enables Windows Updates for APP-V, ACCEPTEULA=1 is necessary to be able to run the installer silently. The end result of the script will look something like this:

# check powershell version
$x=$psversiontable.psversion.Major
if ($x -lt 3 ) {
     #  get OS architecture
     $os=Get-WmiObject  Win32_OperatingSystem  | select OSArchitecture
     if ($os -match "32-bit")  {
        wusa.exe \\servershare\WINRT\Windows6.1-KB2506143-x86.msu /quiet /norestart  } 
     else {
         wusa.exe \\servershare\WINRT\Windows6.1-KB2506143-x64.msu /quiet /norestart  
      }
} else {
      $isthere=test-path "HKLM:SOFTWARE\Microsoft\APPVclient"
      if ( $isthere -eq $false) {
         start-process -FilePath "servershareappv_clients5SP1APPV_CLIENT_SETUP.exe" -ArgumentList "/MUOPTIN=1  /ACCEPTEULA=1 /q /norestart" -Wait     }
}

 

This Powershell script then can be run as a Startup script using a Group Policy (Computer Settings, Windows Settings, Scripts, Startup, tab PowerShell scripts)

Share on FacebookTweet about this on TwitterShare on LinkedInEmail this to someone