How to uninstall programs using PowerShell

Powershell Script to Uninstall a program

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()












    • Related Articles

    • How to find unused Exchange Online mailboxes

      What are unused Exchange Online mailboxes and how to identify them? Unused Exchange Online mailboxes are user mailboxes which are currently not being used by their users. There are 3 ways in which we can identify if a mailbox is unused or not. They ...
    • Generate an Activity Report for Microsoft 365 Groups and Teams

      Introduction The activity reports available for Microsoft 365 groups and Teams can be beneficial for administrators in an organization. Microsoft 365 teams group activity reports provide insight into group activities, group workloads, group counts, ...
    • Powershell Script to Find and Replace Text in a File

      To find and replace a particular word throughout a file on multiple computers is as laborious as one can imagine. However, with the help of the following PowerShell script, one can easily find a particular word and replace it with a word of choice.   ...
    • Powershell Script to Delete Files Older than X days

      Files and folders can accumulate over time and take up considerable space in the database or hard drives and end up slowing the computer considerably. However, deleting them manually isn't quite scalable. This is where PowerShell scripts can be of ...
    • PowerShell for AD group reports

      Real-time insights on group membership, type, and scope can help Active Directory (AD) administrators manage group objects better. Many administrators use Microsoft's PowerShell technology to run basic queries and pull detailed information. Below are ...