Uninstall set of programs using Powershell

I have a set of programs I would like to uninstall with Powershell.

Get-WmiObject Win32_Product | where-Object {$_.name -Like "MySQL*"}

How do I pipe this to an uninstall function?

Some questions seems to use msiexec, but others recommend .uninstall()?

9

1 Answer

You could take the existing output and call Uninstall() for each product:

Get-WmiObject Win32_Product | where-Object {$_.name -Like "MySQL*"} | ForEach-Object { $_.Uninstall() }

Just be very sure you want to uninstall every product starting with "MySQL".

It should also be quicker if you do your filtering from the WMI query:

Get-WmiObject Win32_Product -Filter "name LIKE 'MySQL%'" | ForEach-Object { $_.Uninstall() }

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like