Uninstall application with MSIEXEC from PowerShell (command works from cmd.exe)


I’m trying to execute the following without any prompts


$CustomApp = gci “HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall” | foreach { gp $.PSPath } | ? { $ -match “SOFTWARE NAME” } | select UninstallString

$CustomApp = $CustomApp.UninstallString -Replace “msiexec.exe”,“” -Replace “/I”,“” -Replace “/X”,“”

start-process “msiexec.exe” -arg “/X $CustomApp /qn” -Wait



As soon as I execute the script, the Windows Installer “msiexec /option” toolbox opens up.

When I run the following via command prompt, the application uninstalls perfectly:

msiexec.exe /x {B9F71840-996F-462F-8FBB-F3A0A35316D4} /qn


All workstations where I need to uninstall the application has 64-bit Windows. Any help would be appreciated.

You could print the $CustomApp variable to verify whether proper arguments are built. Better don’t use $CustomApp variable for argument building as its used above and will be of different type. Its not a good practice.

You can do this more easily with get-package and uninstall-package. They support the msi provider.

Hi kvprasoon

Can you elaborate more or give an example. Sorry, but still a bit new to PowerShell.



The Get-Package and Uninstall-Package did the trick. Thank you very much!

This is how the command looks like:

[pre]Get-Package -Name “SOFTWARE NAME” | Uninstall-Package -Force[/pre]