Searching the Registry Uninstall Key with PowerShell

Here’s a little PowerShell function I wrote that searches the Uninstall key in the registry for DisplayNames and product code GUIDs.  I wrote it to help in finding the relevant uninstall key to use for the registry detection method when creating new applications in System Center Configuration Manager.  You can use it to output all the DisplayNames and GUIDs in the key, or search for a keyword to filter the results.  On 64-bit systems, it can also search the Wow6432Node.

UPDATE! – Oct-16-2015 – Script updated to include “DisplayVersion” key.

Examples

Output all the DisplayNames and GUIDs in the 32-bit and 64-bit uninstall registry keys to GridView:

Search-RegistryUninstallkey -Wow6432Node | Out-GridView

Capture

Search for all products with “Apple” in the DisplayName (excluding the Wow6432Node):

Search-RegistryUninstallkey -SearchFor "Apple"

Capture

Search for all products with “Apple” in the DisplayName (including the Wow6432Node):

Search-RegistryUninstallkey -SearchFor "Apple" -Wow6432Node

Capture

Code

function Search-RegistryUninstallKey {
param($SearchFor,[switch]$Wow6432Node)
$results = @()
$keys = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | 
    foreach {
        $obj = New-Object psobject
        Add-Member -InputObject $obj -MemberType NoteProperty -Name GUID -Value $_.pschildname
        Add-Member -InputObject $obj -MemberType NoteProperty -Name DisplayName -Value $_.GetValue("DisplayName")
        Add-Member -InputObject $obj -MemberType NoteProperty -Name DisplayVersion -Value $_.GetValue("DisplayVersion")
        if ($Wow6432Node)
        {Add-Member -InputObject $obj -MemberType NoteProperty -Name Wow6432Node? -Value "No"}
        $results += $obj
        }

if ($Wow6432Node) {
$keys = Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | 
    foreach {
        $obj = New-Object psobject
        Add-Member -InputObject $obj -MemberType NoteProperty -Name GUID -Value $_.pschildname
        Add-Member -InputObject $obj -MemberType NoteProperty -Name DisplayName -Value $_.GetValue("DisplayName")
        Add-Member -InputObject $obj -MemberType NoteProperty -Name DisplayVersion -Value $_.GetValue("DisplayVersion")
        Add-Member -InputObject $obj -MemberType NoteProperty -Name Wow6432Node? -Value "Yes"
        $results += $obj
        }
    }
$results | sort DisplayName | where {$_.DisplayName -match $SearchFor}
} 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s