1) Have you thought about just pulling the %PACKAGEINSTALLATIONROOT% from the registry as opposed to having it manually defined in the script?
$AppVClientPath = 'D:\App-V' #This is the path to your %PackageInstallationRoot%, if you only have a single location, use the same value for the next variable as well
$AppVClientPath2 = 'D:\App-V' #This is the path to your secondary %PackageInstallationRoot%, if you have different locations (XenApp vs VDI, etc)
2) Since you require the full AppV infrastructure, you could query the Publishing Server for the management server, which has commands to display all packages. Example:
#Get publishing server
$url = dir HKLM:\SOFTWARE\Microsoft\AppV\Client\Publishing\Servers
$url.GetValue("URL")
$pubServer = [uri]$url.GetValue("URL")
#get MGTserver remotely from publishing server
$w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$pubServer.host)
$keypath = 'SOFTWARE\Microsoft\AppV\Server\PublishingService'
$MGTServerReg = $w32reg.OpenSubKey($keypath)
$MGTServer = $MGTServerReg.GetValue('PUBLISHING_MGT_SERVER')
#query MGTServer for all packages
$MGTServerURI = [uri]$MGTServer
[xml]$Packages = Invoke-Webrequest -uri $MGTServerURI/packages -Method Get -UseDefaultCredentials
#find AppVClient package
$appVClient = $packages.ArrayOfPackageVersion.PackageVersion.packageurl | sls "Microsoft App-V5.0 Client UI"
You may want to cleanup the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppV\Client\Virtualization\LocalVFSSecuredUsers
Registry key as well. :)
Thanks for making this!