Unnecessary applications accumulated over time can take up considerable memory and slow down the performance of a computer. This problem is especially relevant as Windows 10 comes with a plethora of built-in applications like Photos, Voice Recorder that cannot be uninstalled from the Control Panel. However, applications can be removed easily with the help of PowerShell scripts like the following.
How to uninstall programs using PowerShell
To uninstall a certain application from your computer, provide the application name as the parameter and run the script.
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()