Uninstall programs in Windows using PowerShell.

In this article, we will look at how to uninstall installed programs on a local and remote computer in Windows using PowerShell. Quite often scripts and automation scripts have to use various blocks of code to remove installed Windows programs. You can use several approaches to remove programs from the command line or PowerShell scripts.

Removing Installed Programs Using WMI.

The most common way to remove installed programs on Windows is to use commands that refer to the WMI namespace. For example, using the wmic utility, you can list installed programs:

wmic product get name,version


To silently remove a program from this list, you can use the following command:

wmic product where name="VMware vCenter Converter Standalone" call uninstall /nointeractive
The command will call the WMI method for uninstalling the program through the Windows Installer.

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

If the uninstallation of the program is successful, it will return:

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

Similar PowerShell commands for displaying and removing programs via WMI:

Get-WmiObject Win32_Product | ft name,version,vendor,packagename
(Get-WmiObject Win32_Product -Filter "Name = 'XXX'").Uninstall() 
To uninstall a program on a remote computer, add the –ComputerName parameter. For example, to uninstall Microsoft Office on a remote computer, run:

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

However, this method of uninstalling the program will not be universal. If you compare the list of programs that is returned via WMI namespace and the list of programs in the Windows 10 Control Panel (command ms-settings:appsfeatures ), you will see that they are different. The command displayed a list of programs installed through the Windows Installer. The list does not include most user programs (for example, browsers).

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

Uninstall a program on a remote computer using the Package Manager PowerShell module.

In modern versions of Windows 10/11 and Windows Server 2022/2019/2016, you can use cmdlets from the PowerShell Package Management module to install and remove programs . Initially, the module was used to install/remove PowerShell modules. However, you can also use it to uninstall Win32 programs, MSU updates, programs installed using MSI installers.

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

Get-Package

The command will return several application classes installed through different providers (ProviderName). A complete list of available providers on a computer can be displayed like this:

Get-PackageProvider
  • Programs
  • Msi
  • Msu
  • PowerShellGet
  • NuGet


To list programs installed with a specific provider, run:

Get-Package -ProviderName Programs -IncludeWindowsInstaller
To uninstall the program, use the Uninstall-Package cmdlet:

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

You can remove the installed PowerShell module. For example, to remove 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 Msk-Ser01 -ScriptBlock { Get-Package -Name "Notepad++*" | Uninstall-Package}
WinRM PowerShell Remoting can be enabled on computers using a GPO.

This module can only be used to uninstall Win32 programs and modules. To uninstall Microsoft Store UWP apps, you need to use the PowerShell cmdlets Remove-AppxPackage and Remove-AppxProvisionedPackage.

Using the WinGet Package Manager to Remove Installed Programs.

You can use the new winget package manager (built into modern versions of Windows 10 and 11) to install and remove programs on Windows. To display a list of programs on your computer, run:

Winget list

The command will return a list of programs, including those installed not through winget, as well as a list of UWP applications.


To remove programs installed via WinGet, you need to run the command:

winget uninstall --name 7zip.7zip
To remove an MSI Windows application, you need to specify its GUID:

winget uninstall --id "{332C1E78-1D2F-4A64-B718-68095DC6254B}"
To uninstall a UWP app:

winget uninstall --id "Microsoft.ZuneVideo_8wekyb3d8bbwe"

However, winget does not allow you to uninstall programs on a remote computer. To run winget commands on a remote computer, you need to use PowerShell Remoting features (Invoke-Command and Enter-PSSession cmdlets ). For example:

Invoke-Command -ComputerName pc2122sd1 -ScriptBlock {winget uninstall --name 7zip.7zip}
You can use the PowerShell scripts discussed here to remotely uninstall programs, or to run commands on computers on the network via SCCM or GPO logon scripts.

Отправить комментарий

Добавлять новые комментарии запрещено.*

Новые Старые