Assistance please for uninstalling software

Hello All – We need to uninstall a program from over 1k Windows PCs. Traditionally we could do this via running a MSI command on the local pc via script or SCCM. e.g.: Msiexec.exe /x {%ProgramToRemoveGUIDstring%}

However there are multiple versions in use with their own product GUID. It would be a nightmare to try and get each unique ID and run them on the PCs. Scripting seems the way to go. So far we have tried (with success) two different PowerShell scripts:

$application = Get-WmiObject -Class Win32_Product -Filter “Name = ‘TeamViewer Host’”


While the above works, we can’t use it due to it causing major issues. (See this: WMI Remove is EVIL) Another PS that does work, but not well for us would be:

Get-Package -Name “Program Name” | Uninstall-Package

When the above runs, we are prompted to install the PS NuGet module, which our security team will not allow. So can anyone think of any other PowerShell script that could do this for us? Or hell even an old skool VBS/Cscript/Wscript?

I know you’re looking for quick solution but this nightmare seems like your best solution.

But since you’re talking about 1K systems you should do some testing first, see this spcific answer on SO:

I would personally use this code and improve it for my case, or even better make it universal to fit more advanced use cases, ex. to be reusable in the future.

What program are you trying to remove? I hope it’s not SQL server or something like that.

If there are multiple packages that are all part of same suite, you’ll have to write some registry drilling function to first gather all info and only then start removing components, probably taking care of removal order to avoid issues.

I was going to suggest the UninstallString from the registry as well. Vote++

Thanks @metablaster you saved me!. The SO script worked and testing verified it. The first PS script used the Wim32_Product call in the script and that caused issues, even though it did remove the software. The second PS script we found didn’t use any WMI calls, but it would immediately prompt to install the NuGet module. That wouldn’t work. So the script on SO above did it! I copied and pasted this into our task sequence step in SCCM/MECM, and good to go! Thanks boss.

1 Like