2

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}"
    }
}
4
  • 2
    No need to reinvent the wheel. See here: Windows IT Pro - Auditing 32-bit and 64-bit Applications with PowerShell. Commented Feb 17, 2016 at 16:05
  • Here is a module that gives access to a lot of MSI functionality. Commented Feb 17, 2016 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. Commented Feb 17, 2016 at 16:43
  • @Bill_Stewart - Thanks. I'll take a look. Commented Feb 17, 2016 at 16:43

1 Answer 1

1

replace this

Write-Output "${app.DisplayName}"

with this

Write-Output "$($app.DisplayName)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.