Identifying unused App-V 4.6 SP2 applications and writing them to a new multi-string reg key for easy identification
I ran into an interesting situation with a customer a while back where they needed a way to identify the virtual applications that weren't being used on the workstations in their environment.
Due to the state of their environment, we weren't able to pull information from the App-V server because the App-V clients weren't sending their usage data up to the server so there wasn't an easy way for us to pull the data. They weren't staying on top of patching their servers and ensuring the latest updates and fixes were applied.
We ended up using ConfigMgr to blast out this script to all workstations and extended the MOF to report on this key. We were then able to use ConfigMgr's reporting to identify the unused apps and remove them from the workstations. This helped keep things clean and tidy for licensing purposes.
This script reads all the App-V packages located on a machine (see pic below), finds any of them with the LastLaunch key set to 0 and writes those apps to a new multistring registry key.
]--------- Begin Code ---------[
#sets registry location to variable
$path = 'HKLM:\SOFTWARE\Microsoft\SoftGrid\4.5\Client\Packages'
#loops through ...\Packages reg key
$names = Get-ChildItem $path -recurse
#initializing array
$newkey = @()
#creates new registry key to report on in ConfigMgr
New-ItemProperty -path $path -name UnusedVirtApps -PropertyType MultiString -force
<# Loops through each subkey in ...\Packages reg key and if the LastLaunch
reg key equals zero, writes the name of the app to the UnusedVirtApps reg key #>
foreach($property in $names)
{
$values = $property | foreach {Get-ItemProperty $_.pspath}
foreach ($value in $values)
{
if ($value.LastLaunch -eq "0")
{
$full = $value.name + ","
$newkey = $newkey + $full
Set-ItemProperty $path -name UnusedVirtApps -value ($newkey)
write-host $value.name
}
}
# Disposing of $property variable
$property.Dispose
}
#end
]--------- End Code ---------[
Thanks for reading!