Powershell Script to Uninstall a program

Supply the program name as parameter to uninstall the program from your machine.

Script

<#
.SYNOPSIS
This script can be used to uninstall a program.
.DESCRIPTION
This script can be used to uninstall a program.
.EXAMPLE
C:\PS> C:\Script\Uninstall_a_program.ps1 “firefox”
Uninstalls the program firefox.
#>

param ([string]$deleteapp)
#Obtain a WMIobject of class Win32_Product with the name of the application to be removed.

$app = Get-WmiObject -Class Win32_Product -Filter “Name = ‘$deleteapp'”
#Uninstall the application.

$app.Uninstall()

 

Output
Uninstall

Leave a Reply