I need to grab the UninstallString
for a specific software package from
the Windows Registry. Unfortunately, there are a number of different versions
of the package installed, so I need to query it by package name. I've found
examples of how to do this here and here. I wrote a test script to
validate that I was grabbing the correct application. This test script
should write the display name of the application to the console. However,
it is instead writing a blank line. I get the same results when I attempt to
write the UninstallString
to the console.
$PATHS = @("HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
$SOFTWARE = "SOFTWARE_NAME"
ForEach ($path in $PATHS) {
$installed = Get-ChildItem -Path $path |
ForEach { Get-ItemProperty $_.PSPath } |
Where-Object { $_.DisplayName -match $SOFTWARE } |
Select-Object -Property DisplayName,DisplayVersion,UninstallString
ForEach ($app in $installed) {
Write-Output "${app.DisplayName}"
}
}