How to create a PowerShell command to uninstall an application

First, identify the applications in the list from this command:

#Get App 
Get-WmiObject -Class win32_product

Next, filter to the app you want to remove: I'm testing here with "Advanced installer".

#Filter to just the app name
Get-WmiObject -Class win32_product -Filter "Name like '%Advanced Installer 16.5%'"

Next, check the locate the uninstall module:

#Locate the Uninstall() Method of the Win32_Product Class using the Get-Member cmdlet:
Get-WmiObject -Class win32_product -Filter "Name like '%Advanced Installer 16.5%'" | gm

Finally, contstruct your uninstall command like this:

#Use the uninstall method to uninstall.
Get-WmiObject -Class win32_product -Filter "Name like '%Advanced Installer 16.5%'" | ForEach-Object { $_.Uninstall()}

Add comment