Retrieve UninstallStrings to fix installer issues

Recently I have encountered several installer related issues on my machine. Most of them seemed to be caused by insufficient privileges.
This kind of issue can be usually fixed by running the installer “As Administrator”. In case the issue is in relation to an already installed software packet, it’s sometimes not so easy to locate the respective uninstaller/MSI packet, though. For that purpose, I’ve written a small PowerShell function that scans the registry (it turned out that if you are using PowerShell v5, there is a better way of doing this. See below for more details) (have a look here on why I didn’t want to use WMI Win32_Product instead) for the information. The function has the following features:

  • Search for software by name including wildcards (parameter DisplayName defaults to ‘*’)
  • Search through user specific (HKCU) and/or machine specific (HKLM) registry hives (parameter Hive defaults to HKLM, HKCU only accepts a combination of ‘HKCU’ and/or ‘HKLM’)
  • If a key is found matching the DisplayName. Output an object with the following properties: RegistryHive, DisplayName, UninstallString, msiGUID (if present), InstallLocation=$subKey.InstallLocation, Version (DisplayVersion)

Usage (if your PowerShell version < 5):

#search for the chrome uinstaller only in the machine wide registry hive
Get-Uninstaller *chrome* -Hive HKLM

If you happen to be on PowerShell v5 ($PSVersionTable.PSVersion.Major -eq 5) you can use the built-in Get-Package to retrieve the same information:

#requires -Version 5
Get-Package | foreach{
$attributes = $_.meta.attributes
$htProps = [Ordered]@{msiGUID=''}
for ($i=0;$i -lt $attributes.keys.count;$i++){
if ($htProps.Contains('DisplayName')){
$uninstallString = $htProps.UninstallString
$modifyPath = $htProps.ModifyPath
if($uninstallString -match "^msiexec"){
$htProps.msiGUID = [regex]::match($uninstallString,'\{(.*?\})')
elseif($modifyPath -match "^msiexec"){
$htProps.msiGUID = [regex]::match($modfiyPath,'\{(.*?\})')
New-Object PSObject -Property $htProps #| select DisplayName, UninstallString, msiGUID, InstallLocation, Version

Armed with that information one can easily run the installer (MSI) or uninstall routine with elevated privileges in order to fix some installer related issues. For msi installer packets the following command will reinstall the respective software (see here for more details on the reinstall mode). It hopefully goes without saying, that you should only run those commands if you know what you are doing:

msiexec /i {msiGUID} REINSTALL=ALL REINSTALLMODE=omus /l*v log.txt

Below is the source of the helper function for older PowerShell version. I have also uploaded another adaption that uses the best approach depending on the PowerShell version, to my GitHub repo.

function Get-Uninstaller {
$DisplayName = '*',
[ValidateSet('HKLM', 'HKCU')]
[string[]]$Hive = @('HKLM','HKCU')
$keys =@'
'@ -split "`r`n"
foreach ($currHive in $Hive){
foreach($key in $keys){
$key = "$currHive" + "$key"
if(Test-Path $key){
$subKeys = Get-ItemProperty "$key\*"
foreach($subKey in $subKeys){
if($subKey.DisplayName -like "$DisplayName" -and $subKey.UninstallString){
$uninstallString = $subKey.UninstallString
$modifyPath = $subKey.ModifyPath
$htProps = [Ordered]@{
if($uninstallString -match "^msiexec"){
$htProps.msiGUID = [regex]::match($uninstallString,'\{(.*?\})')
elseif($modifyPath -match "^msiexec"){
$htProps.msiGUID = [regex]::match($modfiyPath,'\{(.*?\})')
New-Object PSObject Property $htProps


Photo Credit: Chad Sparkes via Compfight cc

One thought on “Retrieve UninstallStrings to fix installer issues

  1. Hi,

    thanks for the information. That’s exactly what I was searching for.

    Just to mention: Your Powershell v5 solution can be improved by changing the first line from

    Get-Package | foreach{


    Get-Package -IncludeWindowsInstaller | foreach{

    Best regards

    Liked by 1 person

I'd love to hear what you think

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

You are commenting using your 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 )

Connecting to %s