PowerShell for Windows Admins

Jul 16 2010   6:59AM GMT

Uninstalling software



Posted by: Richard Siddaway
Automation, PowerShell v2, Software, WMI

The Win32_Product class can be used to list the installed software (what shows in Control panel Programmes and Featurs) on a machine.  it can also be used to uninstall software.

We can see the installed software

Get-WmiObject -Class Win32_Product

we can filter down to the results we need

Get-WmiObject -Class Win32_Product -Filter “Name LIKE ‘%TechNet%’”

The specific version to uninstall is selected

$t = Get-WmiObject -Class Win32_Product -Filter “Name = ‘TechNet Library – English DVD (March 2010)’”

and then we call the uninstall method

$t.Uninstall()

A return code of zero indicates a successful uninstall. Anything else and we have problems.

This method doesn’t delete items from the start menu – which is a job for another time

Comment on this Post

Leave a comment: