Search for Uninstall Strings

This Powershell Script will search through your registry and locate uninstall strings for your 32bit and 64bit programs. It is very easy to use and all you have to do is type in the name of the program to locate the uninstall string.

$appname = read-host "Enter your program name"
$32bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"}
$64bit = get-itemproperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"}


if ($64bit -eq "" -or $64bit.count -eq 0) {

    switch ($32bit.DisplayName.count) {
        0 {Write-Host "Cannot find the uninstall string" -ForegroundColor Red}
        1 {
            if ($32bit -match "msiexec.exe") {
            $32bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x'
            }
            else
            {
                $32bit.UninstallString 
            }
            }
        default { Write-Host "Please Narrow Down Your Search" -ForegroundColor Red }
    }
}
else {
 
    switch ($64bit.DisplayName.count) {
        0 {Write-Host "Cannot find the uninstall string" -ForegroundColor Red}
        1 {
            if ($64bit -match "msiexec.exe") {
                $64bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x'
            }
            else
            {
                $64bit.UninstallString 
            }
            }
        default { Write-Host "Please Narrow Down Your Search" -ForegroundColor Red }
    }
}

Enjoy!

7 Comments

  1. This script is such a time saver! Nice work Jose, very impressive!

  2. Great script Jose, thanks for this. Looking to implement this into an troubleshooting tool I have created for our helpdesk

  3. Great job Jose! it is going to be very useful for me. Many thanks for sharing.

  4. Great job Jose
    Can we make this script work as silent uninstaller?
    What do we need to do?

    • Jose Espitia

      Yes, you can. You could pass the GUID to a variable and then use msiexec to uninstall the software.

Leave a Reply