Home > Back-end >  Get several Uninstall Strings from Registry with Powershell
Get several Uninstall Strings from Registry with Powershell

Time:10-25

I want to uninstall a program. There can be several versions of this program installed at the same time. I want to uninstall them with the uninstall string from the registry.

I need to get the subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall which contain the words "jump client" and "cloud". If the name of the subkey contains these words, then I need to get the Display Name and the Uninstall String. The Display Name also contains these two words.

For example: I need the Uninstall String and Display Name of "123-Jump Client – 189.38-cloud" and the Uninstall String and Display Name of "245-Jump Client – 184-cloud". enter image description here

I tried

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"|Where-Object {$_.DisplayName -contains "jump client" -and $_.DisplayName -contains "cloud"}

That does not work.

Thanks!

CodePudding user response:

The -contains operator searches for an item in an array of items (exact, though case-insensitive match).

In your case you would use

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | 
Where-Object {$_.PSChildName -like '*jump client*cloud'} | 
Select-Object DisplayName, UninstallString

The -contains operator is often confused with the string objects .Contains() method which searches for a substring within a string.

CodePudding user response:

Complementing Theo's helpful answer, you may already filter by using wildcards for the -Path argument of the Get-ItemProperty command:

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*Jump Client*cloud" | 
    Select-Object DisplayName, UninstallString

In case the software is 32-bit, then on a 64-bit Windows, you'd have to search in the 32-bit view of the registry:

Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*Jump Client*cloud" | 
    Select-Object DisplayName, UninstallString

See 32-bit and 64-bit Application Data in the Registry

  • Related