Saturday, April 23, 2011

Blog Post: Function in PowerShell script to uninstall program

This script helps you to uninstall programs using PowerShell as to make it dynamic I made it as function so you can bypass the name of the program that you want to uninstall it

[sourcecode language="powershell"] function uninstallapp ($x) { $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match "$x" } $app.Uninstall() } [/sourcecode]

Here you can find how to run it

PS C:\Windows\system32> uninstallapp "microsoft lync 2010"

below you will get result like this one

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0

Julie Berry Lori Heuring Nicole Scherzinger Jill Arrington Tami Donaldson

No comments:

Post a Comment