Uninstalling Programs with PowerShell in Windows 10/11 | Ranjan.info

In this article, we will see how to uninstall software on a local or remote Windows computer using PowerShell. Often, the system administrator uses scripts to uninstall Windows applications. You can use several methods to remove a program from the Command Prompt or PowerShell script.

Using WMI to Uninstall Programs in Windows

The most common way to remove installed programs on Windows is to use a command that refers to the WMI namespace. For example, you can query the WMI namespace and get a list of installed programs wiki command.

wmic product get name,version

wmic get product name, version - get list of installed apps

To silently uninstall an application from this list, you can use the command below:

wmic product where name="VMware vCenter Converter Standalone" call uninstall /nointeractive

The command calls an app uninstallation WMI method via Windows Installer.

Executing (\\COMPName\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{PROGRAM_GUID}",Name="VMware vCenter Converter Standalone",Version="6.2.0.8466193")->Uninstall()

If the program has been successfully uninstalled, it will return:

Method execution successful. Out Parameters: instance of __PARAMETERS {
ReturnValue = 0; };

Here are similar PowerShell commands to display and uninstall apps via WMI:

Get-WmiObject Win32_Product | ft name,version,vendor,packagename
(Get-WmiObject Win32_Product -Filter "Name="XXX"").Uninstall()

To remove a program on a remote computer, add -computer name alternative. For example, to uninstall Microsoft Office on a remote computer, run the following command:

$apps = Get-WmiObject -Class Win32_Product -ComputerName wkmn-man23 |where name -Like "Office 16 Click-to-Run*"
$apps.uninstall()

However, this method of deleting applications is not universal enough for all possible cases. If you compare the list of programs returned via the WMI namespace and the list of apps in Windows Control Panel/Apps and Features in Settings (use the ms-settings quick access command: ms-settings:appsfeatures), you will see that they differ. The wmi command only displayed a list of programs installed through Windows Installer. The list does not include most user apps (e.g. browsers).

Also, UWP programs and PowerShell modules (via PowerShellGet) from the Microsoft Store are not displayed.

Uninstall Apps on Remote Computer with PowerShell Package Manager Module

In modern Windows 10/11 builds and Windows Server 2022/2019/2016, you can use the built-in PowerShell package management cmdlets to install or uninstall apps. Originally, Modules was used to install/uninstall PowerShell modules. However, you can use it to uninstall Win32 programs, MSU updates, and apps installed using the MSI Installer.

To display a complete list of installed apps on the local computer, run the command below:

Get-Package

Get-Package - Powershell: Export List of Apps

The command returns several classes of programs installed through different providers (provider names). You can display the list of providers on the computer as follows:

Get-PackageProvider

  • programs
  • msi
  • Musso
  • powershellgate
  • nugget

List Package Provers in Windows 10

To show a list of programs installed through a specific provider, run this command:

Get-Package -ProviderName Programs -IncludeWindowsInstaller

Use uninstall-package cmdlet to remove program:

Get-Package -Name "Notepad++*" | Uninstall-Package

You can remove installed powershell module. For example, to uninstall all VMware.PowerCLI modules:

Get-Package -ProviderName PowerShellGet -Name "VMware.*" | Uninstall-Package

To uninstall a program on a remote computer, use the Invoke-Command cmdlet:

Invoke-Command -ComputerName mun-dc01 -ScriptBlock { Get-Package -Name "Notepad++*" | Uninstall-Package}

You can use this module to uninstall only Win32 apps and PS modules. To remove UWP apps from Microsoft Store, use this Remove-AppxPackage either Remove-AppxProvisionedPackage PowerShell cmdlets (see an example in this article).

How to uninstall app with WinGet command?

you can use new wingate Package Manager (it’s built into Windows 10 and 11) for installing and removing programs on Windows. To get a list of programs on your computer, run:

winget list

The command returns a list of programs including programs and UWP (appx) apps installed using methods other than Winget.

winget list installed apps

To remove apps installed via WinGet, run the command below:

winget uninstall --name 7zip.7zip

To uninstall an MSI app in Windows, specify its GUID:

winget uninstall --id "{332C1E78-1D2F-4A64-B718-68095DC6254B}"

To uninstall the UWP app:

winget uninstall --id "Microsoft.ZuneVideo_8wekyb3d8bbwe"

cmd.  uninstall application from winget

However, Winget does not allow you to uninstall programs on remote computers. To execute winget commands on a remote computer, use the PowerShell remoting features (the Invoke-Command and Enter-PSession cmdlets). For example:

Invoke-Command -ComputerName wkmn-man231 -ScriptBlock {winget uninstall --name 7zip.7zip}

You can use the PowerShell script shown here to remotely uninstall programs or run them on a domain computer using a SCCM or GPO logon script.

Leave a Comment