Uninstall Software Application with PowerShell

The following code will query the WMI database for installed applications that match what is specified and then invoke the Uninstall() command.

This PowerShell command comes very handy when writing removal scripts.

Get-WmiObject -Class Win32_Product | Select-Object Name | Sort-Object Name

Then after you know the exact product name, use the following command to uninstall.

$uninstallApp = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -Match "SomeApp"}; $uninstallApp.Uninstall()

Since I’m using the match command, I would recommend querying for the exact application name by running. This is recommended that way you know exactly what you’re removing.

You can also use the “-Like” switch, but you have to be very careful. If you wanted to remove Acrobat and said Where-Object {$_.Name -Like “Adobe*”} it would remove everything matching “Adobe”. Just try to be aware of this.

$uninstallApp = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -Like "SomeApp*"}; $uninstallApp.Uninstall()

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.