Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / PowerShell / Uninstalling Programs with PowerShell in Windows 10/11

October 19, 2022 PowerShellWindows 10Windows 11Windows Server 2019

Uninstalling Programs with PowerShell in Windows 10/11

In this article, we’ll look at how to uninstall software on a local or remote Windows computer using PowerShell. Quite often, the system administrator uses scripts to uninstall Windows applications. You can use several approaches to remove programs from the command prompt or PowerShell scripts.

Contents:
  • Using WMI to Uninstall Programs in Windows
  • Uninstall Apps on Remote Computer with PowerShell Package Manager Module
  • How to Uninstall App with WinGet Command?

Using WMI to Uninstall Programs in Windows

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

wmic product get name,version

wmic product get name,version - get list of installted appd

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

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

The command calls an app (vCenter Converter) uninstallation WMI method 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 program is 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()

In order to remove a program on a remote computer, add the -ComputerName option. For example, to uninstall Microsoft Office on a remote computer, run the command below:

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

However, this method of removing 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 the Windows Control Panel/ Apps & features list 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 the Windows Installer. The list doesn’t include most user apps (browsers, for example).

full list of instaled programs in windows 10

In addition, UWP programs from the Microsoft Store, and PowerShell modules (via PowerShellGet) 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, the module was used to install/uninstall PowerShell modules. However, you may use it to uninstall Win32 programs, MSU updates, and apps installed using MSI installers as well.

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

Get-Package

Get-Package - Powershell: Export List of apps

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

Get-PackageProvider

  • Programs
  • Msi
  • Msu
  • PowerShellGet
  • NuGet

list package proveders in windows 10

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

Get-Package -ProviderName Programs -IncludeWindowsInstaller

Use the Uninstall-Package cmdlet to remove the program:

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

You can remove the 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 enable WinRM PowerShell Remoting on domain computers via GPO.

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

How to Uninstall App with WinGet Command?

You can use the new WinGet package manager (it is built into Windows 10 and 11) to install and remove programs on Windows. To get a list of programs on your computer, run:

winget list

The command returns a list of programs including those installed using other methods than winget and a list of UWP (APPX) apps.

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 a UWP app:

winget uninstall --id "Microsoft.ZuneVideo_8wekyb3d8bbwe"

winget uninstall application from cmd

However, winget doesn’t allow you to uninstall programs on a remote computer. To execute winget command on a remote computer, use the PowerShell Remoting features (Invoke-Command and Enter-PSSession cmdlets). For example:

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

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

0 comment
0
Facebook Twitter Google + Pinterest
previous post
Configuring Remote Desktop Services (RDS) Farm on Windows Server
next post
How to Send a Message to Teams Channel with PowerShell

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top