PowerShell Oneliner: Load All Non-Cached App-V 4 Packages Into the Cache Print E-mail
Written by Darwin Sanoy   
Wednesday, October 9, 2013 6:31am
During an SCCM 2007 to SCCM 2012 migration my team had an unsavory discovery about the App-V 4.6 packages that had been deployed under SCCM 2007.  After the migration, if a user launched an App-V application that hadn't been launched *at least once before* the migration - App-V would attempt to load the App-V cache by looking in the old SCCM 2007 cache location - which was now gone.  Citrix was where this really hurt.  This article contains PowerShell Oneliner you might want to run *before migration* to avoid this problem.

When you reinstall the SCCM client, the cache is in a different location and some or all of the old location may be cleaned up.

It also appears that the registry of both the SCCM client and the App-V client maintain the *old* pointer, even after re-installing the App-V package from SCCM 2012.  This includes the sequence of: [1] Reinstall App-V using SCCM 2012, [2] Uninstall using SCCM 2012, [3] Install again using SCCM 2012.  In these scenarios, launching the package *STILL* tries to load from the old SCCM 2007 cache location.  It would seem that App-V does not clean out this key on an App-V package uninstall and SCCM 2012 is not using the key.

To help with this problem, new SCCM 2012 App-V Deployment Types shoud enable the options for "Download Content from distribution point and run locally" (both options) and "Load Content Into Cache Before App-V Launch" - both of these are on the "Content" tab of any App-V Deployment Type.

If you instruct all your App-V clients to forcibly load the cache for any App-V packages that are not loaded *before* you migrate off of 2007 to 2012, you could save yourself a lot headaches.  This is the equivalent of having user's run the App-V package at least once.  It must be done before migration while the SFT is still available in the SCCM 2007 cache location.

If you use the below command, you should be aware that if the cached package is missing from the SCCM 2007 cache, the package will not get loaded (but not generate any errors to the user).  This means this remediation step will reduce your problems, but may not eliminate them 100%.  If errors are generated, they are logged to the EventLog - so you could add code to check the log if you really want zero exceptions.

Here is the PowerShell that will load any non-loaded App-V SFTs into the App-V cache:

Get-WmiObject Package -Namespace root/microsoft/appvirt/client | Where-object {$_.CachedSize -eq 0} | foreach-object {write-host $_.name ; start-process "sftmime" "LOAD PACKAGE:`"$($_.Name)`"" -wait}