Remotely Uninstalling A Program Using PowerShell

If you don’t have a software deployment tool, such as PDQ Deployment, uninstalling a program remotely on a computer could be painful. With PowerShell, it could make the process a lot easier.

Uninstalling a program via WMI

First, let’s see how to view the installed program.

Get-CimInstance -Class Win32_Product -ComputerName $computername

To specify which program, you can pipe the result to Where-Object with a query like this.

Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe Acrobat 2017'}

You can even use the wildcard in this case to find all Adobe-related programs.

Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe*'}

If the output has only one result, you can simply call up the Uninstall() procedure to uninstall the program.

(Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe Acrobat 2017'}).uninstall()

If the output has multiple results, you can use the ForEach() method to loop through each app and uninstall it.

$apps = Get-CimInstance -Class Win32_Product -ComputerName $computername | Where-Object {$_.Name -Like 'Adobe*'}
ForEach ($app in $apps) {

Uninstalling a program via Uninstall-Package

Not all installed programs can be uninstalled via WMI. If the above method fails, Uninstall-Package would be a good option next in the line. Also, if it’s a MSI installed program, you have a better chance of uninstalling it this way.

Use the Get-Package cmdlet to find the program and pipe the result to Uninstall-Package to get it uninstalled. The nice thing about this method is that you can uninstall a bunch of related programs in one line.

Get-Package -Name "Kofax*" | Uninstall-Package

The drawback is that you would need to use the Invoke-Command cmdlet to execute it on a remote computer.

Invoke-Command -ComputerName $computername -Scriptblock {Get-Package -Name 'Kofax*' | Uninstall-Package

Leave a Reply

Your email address will not be published. Required fields are marked *