How To Uninstall Software With Powershell: 2 Easy Methods To Follow!

How To Uninstall Software With Powershell. Most of us have removed programs from our computers. How did you do it? Can you recall anything?

We have mostly done it through the Control Panel, or in some cases, when dealing with more complicated suites, through their own uninstall process.

These options are useful for removing a single program, but they are not scalable. Consider yourself an IT administrator who needs to remove programs from different computers. It’s not the most efficient option to log into each device as well as uninstall a program.

Fortunately, you can uninstall software using PowerShell scripts. The advantage is that you can send an uninstall command to any number of networked PCs. With just one script, you can uninstall a program from multitudes of PCs.

Sounds easy, doesn’t it? Let’s get started and learn how to uninstall software with PowerShell.

What exactly is Microsoft PowerShell?

What exactly is Microsoft PowerShell?
What exactly is Microsoft PowerShell?

Microsoft PowerShell is an assignment automation as well as configuration manager that includes a scripting language as well as a command-line interface. It includes a plethora of built-in commands known as cmdlets that perform a specific function as well as a task. These cmdlets can be combined into a custom script to perform specific tasks, such as automating complex or time-consuming functions.

How To Uninstall Software With Powershell: 2 Methods for Uninstalling Software

PowerShell has two methods for uninstalling software: the Uninstall() method as well as the Uninstall-Package command. The Uninstall() technique is the most common and easiest method for removing well-known programs from a device.

An Uninstall-Package option is a great option for concealed programs and those that PowerShell does not recognize.

Begin with the first choice.

How To Uninstall Software With Powershell: Method of Uninstallation

This step-by-step guide will teach you how to uninstall the software from a regular computer. You can always utilize a For-each loop to prolong it to a collection or array of PCs and perform the same action on each computer in the array.

Step 1: Obtain a List of Installed Applications

Get a list of applications on a computer as a first step. That is the PowerShell code:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name

You may be wondering why you need to get a list of installed applications. After all, you only need to uninstall one program from the computer. The catch is that you must know the exact name of the application because PowerShell reads as well as displays it.

To uninstall Outlook from a computer, for example, you could use the words “Microsoft Outlook” in your code. What if it’s referred to as “Microsoft Outlook 2019”? This mismatch will either result in an error message or in the command failing to execute.

To avoid confusion, examine how PowerShell reads a software’s name and then use this name exactly in your uninstall code.

Step 2: Trim the List

Even on devices with only a few installed programs, the program list above can appear overwhelming. If you know what your program’s name is, you can use filters as well as regular expressions to narrow it down.

In the preceding example, you can instruct PowerShell to limit the list to programs that contain the word “Outlook,” as this is a distinct word. If you use “Microsoft,” you might get a longer list! In general, choose the expressions but also words that have the best chance of directing you to the program you seek.

$MyProgram = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq “Outlook”}

This will narrow the list down to all of the Microsoft Outlook versions that are installed on your system. Choose the version you would like to uninstall from this list. If you only have one version installed, there is no option to select, and MyProgram stores the significance in the variable.

Step 3: Execute the Uninstall Procedure

Uninstall is a built-in method in PowerShell (). To uninstall your program, simply invoke this method.

This command will remove your program. You can also substitute the variable $MyProgram with the name of the program.

This is the simplest way to uninstall a program with PowerShell. However, some hidden programs might well exist and will not be listed by the Get-WmiObject command.

To test this, open your Control Panel and look at the programs list. When you compare it to the list displayed by PowerShell, you’ll notice that some are missing.

Use Uninstall-Package

Use Uninstall-Package
Use Uninstall-Package

If PowerShell does not recognize your program, select this option. This PowerShell command’s code is,

Get-Package -Provider Programs -IncludeWindowsInstaller -Name “

Use an asterisk in the location of the Name parameter to have PowerShell display all of the programs in the Control Panel. If you’ve placed multiple versions, this command will only uninstall the most recent one.
You can also uninstall a specific version as well as pipe the Get-Package output to Uninstall-Package. Here’s an illustration.

Get-Package -Name ” -RequiredVersion 2.0 | Uninstall-Package

As a result, you can remove any program from a device, even if it is hidden!

Read more: People are wasting no time buying the heavily discounted Galaxy S22 Ultra

Comparison of the Two Methods of Uninstall

So, which of the two should you pick? If Get-WmiObject returns a program, the Uninstall method is the better option. However, if you need to write a custom script to delete programs from multiple computers, use the Uninstall-Package.

Last Words

How To Uninstall Software With Powershell: PowerShell scripts are useful for removing a program from multiple devices. With a few lines of code, you can automate tasks and also save time and effort. PowerShell provides two methods for uninstalling software: Get-WmiObject and Uninstall-Package.

The Uninstall-Package command has more options and allows access to both normal and hidden programs, whereas the Get-WmiObject command can only use associated WMI classes. Which of the two is superior? It is determined by the software you wish to uninstall. If PowerShell’s Get-WmiObject recognizes it, choose this option because it is simpler. Alternatively, use Uninstall-Package.

Leave a Comment