Uninstall Set of Programs Using Powershell

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

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

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.