Remove all unpublished apps to clear package cache

Often I see queries related to clearing leftover package files after unpublishing them. And so here is a sample powershell code to remove all unpublished packages from the system to clear the space they were occupying in the package store.


$allpackages= Get-AppvClientPackage -all|Where-Object {$_.IsPublishedToUser -like "False" -and $_.IsPublishedGlobally -like "False"} | select Name

 $unpublished=$allpackages.name

 ForEach($package in $unpublished)

 {

Write-Host "$package"

Remove-AppvClientPackage "$package"

Write-Host "$package" removed.

 }

NOTE: Test the code in a lab environment, as it doesn't support any error handling.

The case of missing shortcut Icon - App-V 5.X

Recently I have been seeing many queries regarding shortcut Icon not displayed after publishing an virtualized App-V 5.x package. The answer would be quite simple. But I would like to demonstrate it with a simple example so that it can shed some light.


Let us assume a person X has sequenced an application say example Adobe Reader application. He is doing some manual clean up in the package editor. He removed some junk entries to keep the package clean. He also removed the Installer folder that has the installer cache (.msi, .mst, .msp)captured from the installer package as he felt it is also unnecessary junk entries like all others do.





After completing sequencing, he published the package to the machine in a standalone environment and saw that the shortcut icon is missing. He was wondering why the Icon is missing. He came back with a query as why the Icon is missing even after successful sequencing.





Now lets troubleshoot for him. First let's edit the shortcut for icon. We can see that it is looking in %ALLUSERSPROFILE%\Microsoft\AppV\Client\Integration\.....\SC_Reader.ico.





Lets take Procmon capture to get a proper solution. We can see that it is searching for SC_Reader.ico in  the Installer location and the path is not found clearly from procmon trace. When checked manually in the %Allusersprofile% we do see that the Installer folder is missing. This is because the person X has removed it from the package considering it as Junk entries earlier.





We can clearly see that after doing a fresh sequencing of the application that the Icon files are indeed kept in the Windows\Installer folder.





So to conclude do not remove files and folders blindly considering it as junk entries. Do not remove Windows\Installer completely. Perform cleanup with caution. Make sure if removing the Installer folder completely will not affect the functionality.

Right Click and Publish App-V Package along with Dynamic Configuration File - Context Menu Shortcut


In my previous blog I had posted about a simple registry tweak to publish packages globally/User by just right clicking and selecting the option. But in that method, it will not use the dynamic configuration file. And so I have covered how to do that in this blog.


copy the below code in notepad and save it in .reg format. After saving, double click on it and register the keys.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appv]
@="appvex"

[HKEY_CLASSES_ROOT\appvex]

[HKEY_CLASSES_ROOT\appvex\shell]

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally]
@="&Publish Globally"

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish globally.ps1\" \"%1\""

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User]
@="Publish to &User"

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish to user.ps1\" \"%1\""


Publish Globally:


Copy the below code in a notepad and save it as Publish globally.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.


#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _Deploymentconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_DeploymentConfig"))
    {
     $deploymentconfigfile = $xmlFileName
Write-Host "$deploymentconfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile -DynamicDeploymentConfiguration "$deploymentconfigfile" | Publish-AppvClientPackage -Global  | Mount-AppvClientPackage 

}


Publish to User:

Copy the below code in a notepad and save it as Publish to user.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.



#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _userconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_UserConfig"))
    {
     $UserConfigfile = $xmlFileName
Write-Host "$UserConfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile | Publish-AppvClientPackage -DynamicUserConfigurationPath "$UserConfigfile"| Mount-AppvClientPackage 

}


Context Menu Preview:


When you right click any .appv file, it will show the below two context menu shortcuts.If you want to publish globally along with the deploymentconfig file then click on Publish Globally and to publish to a user along with the Userconfig file then click on Publish to User.


Right-Click and Publish AppV packages using ContextMenu Shortcut - A simple registry hack

I always wanted a simple trick to install the App-V virtual packages in a single click without any need to open powershell and type commands in a standalone machine. I have worked on many software's and  used to see some of them provide context menu shortcut (notepad++, winzip etc..) So I had an idea to create a simple registry tweak to publish the virtual packages either globally or to a user by just right clicking a .appv file using context menu option.

Copy the below code and save it in a notepad with .reg extension. Double click and register it.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appv]
@="appvex"

[HKEY_CLASSES_ROOT\appvex]

[HKEY_CLASSES_ROOT\appvex\shell]

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally]
@="&Publish Globally"

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command]
@="cmd /c start /b /wait powershell.exe  -nologo -ExecutionPolicy bypass -command \"& {add-appvclientpackage '%1' |publish-appvclientpackage -global|mount-appvclientpackage}\""

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User]
@="Publish to &User"

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command]
@="cmd /c start /b /wait powershell.exe  -nologo -ExecutionPolicy bypass -command \"& {add-appvclientpackage '%1' |publish-appvclientpackage |mount-appvclientpackage}\""


After registering the registry key, now you should be able to see the below highlighted context menu shortcut when you right-click any .appv file. To publish globally, click on the Publish Globally shortcut and vice versa.





Registry Peak:






Note: This doesn't add the dynamic configuration file while adding/publishing. I will post it separately in my next blog.


Disclaimer - Test it with caution as I don't hold any responsibility for any problem caused. This is issued for experimental purpose only.

Merry Christmas and a Happy New Year!!

If you would like to try on your own refer to the below link which can guide you.

Reference - http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/


Advanced Installer 13.3 - fixes MSI launch condition issue in Windows 10 anniversary update 1607

Earlier when trying to install the Advanced Installer created virtual package through MSI format in windows 10 anniversary update 1607, it failed to install with the below error.




This issue is caused because of a launch condition in MSI which has been set to check for App-V client installed as a pre-requisite. Since App-V comes inbox with windows 10 v1607, the pre-req check fails with the above error.

This was a known issue even with App-V created packages and it was reported back to Microsoft.

Meantime I had a chance to talk with the Advanced Installer team about this issue. They quickly reported that they will look into this issue ASAP and come back with a fix. To my wonder they released an update within a short time period. You can have a look on their release note about this bug fix.

http://www.advancedinstaller.com/release-13.3.html

Now using Advanced Installer 13.3 when you create a virtual package and use the MSI to install in windows 10 1607, it installs fine without any issue. I tested with few apps sequenced by Advanced Installer 13.3 and found it to be 100% success.


So I looked into the MSI created after virtualizing and saw that it had the same launch condition but with a different approach. They have used the APPV_5X_CLIENT_INSTALLED property which has been set using AppSearch.




In this case they have used to locate the registry existence (HKLM\Software\Microsoft\AppV\Client).





Since windows 10 has inbuilt App-V, it  has a registry for AppV with version 5.2.0.0 by default.





Now when you install the new Advanced Installer 13.3 created virtual package MSI, the launch condition gets satisfied as there is a registry key with a valid  version and so it gets installed successfully.


For earlier versions, it still fails. For now you can fix it using the below solutions.


Solution - Virtual applications packaged into MSI format doesn’t install on inbox App-V client in Windows 10 Anniversary update 1607


UPDATED LINK -https://technet.microsoft.com/en-us/itpro/windows/manage/appv-release-notes-for-appv-for-windows