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()?
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() }