1

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}"
    }
}
Community
  • 1
  • 1
Deacon
  • 3,615
  • 2
  • 31
  • 52
  • 2
    No need to reinvent the wheel. See here: [Windows IT Pro - Auditing 32-bit and 64-bit Applications with PowerShell](http://windowsitpro.com/scripting/auditing-32-bit-and-64-bit-applications-powershell). – Bill_Stewart Feb 17 '16 at 16:05
  • [Here](https://github.com/heaths/psmsi) is a module that gives access to a lot of MSI functionality. – Χpẘ Feb 17 '16 at 16:23
  • @Xpw - Thanks. Unfortunately, some of the versions weren't installed from an MSI package. There are versions from three different major releases, at least one of which used a different installer. – Deacon Feb 17 '16 at 16:43
  • @Bill_Stewart - Thanks. I'll take a look. – Deacon Feb 17 '16 at 16:43

1 Answers1

1

replace this

Write-Output "${app.DisplayName}"

with this

Write-Output "$($app.DisplayName)"
Anthony Stringer
  • 1,981
  • 1
  • 10
  • 15