Finding and Removing an application from a windows system using windows Powershell

Recently I wanted to cleanup my system so I thought to do is my favorite way using Powershell, here I am going to share the way you can use find an app using Powershell and uninstall the same.

We are going to use windows management instrumentation (WMI) classes to query system and remove the app from the system.

So let’s start it,

First let’s see what application we have

You can use the GUI to identify the application or you can use the Powershell to Query Installed application on the system.

Get-WmiObject -Class Win32_Product

Get-WmiObject -Class Win32_Product | ft name, Version -AutoSize

I want to remove this BlackBerry Link software as I no longer use Blackberry

Let’s Filter only the app we wants to remove

You can use different ways to filter the applications

Get-WmiObject -Class Win32_Product | ? {$_.Name -like "*BlackBerry*"} Or

Get-WmiObject -Class Win32_Product -Filter { Name = "Blackberry Link" }

Now that we have identified the application so let’s remove the same.

You can Array the Result of the command or you can use the one line to remove the app once identified using the below command.

(Get-WmiObject -Class Win32_Product -Filter { Name = "Blackberry Link" }).uninstall()

Or

$blackberryApp = Get-WmiObject -Class Win32_Product -Filter { Name = "Blackberry Link" }

$BlackberryApp.Uninstall()

You can get more available option by doing the following

(Get-WmiObject -Class Win32_Product -Filter { Name = "Blackberry Link" }) | GM

Or

$BlackberryApp | gm

If you want to remove application from more than one system you can use the bellow script.

$computers = @("computer1", "computer2", "computer3")

foreach($system in $computers){

            $app = Get-WmiObject -Class Win32_Product -computer $system |? {

            $_.Name -like "*BlackBerry*"

} $app.Uninstall() }

For more details please visit the below Technet URL.

http://technet.microsoft.com/en-us/library/dd347651.aspx

Comments