PowerShell for Windows Admins

Jul 16 2010   6:59AM GMT

Uninstalling software



Posted by: Richard Siddaway
Tags:
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

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: