I have a number of Hyper-v Windows Server 2012 R2 core host machines in my environment. Once in a while, I have to check for installed software and uninstall software for maintenance. The following WMIObject class helped me achieve the task in PowerShell.

Check for installed software:

Filter by Software to be Uninstalled:

Locate the Uninstall() Method of the Win32_Product Class using the Get-Member cmdlet:

Use the Uninstall() Method to remove the selected software:

The uninstall task starts to run and immediately restarts the remote server in question to complete the uninstallation. Usually, the return value should be 0 (zero). But in this case, the msi installer triggered an automatic restart to complete the uninstallation.Checking for installed software after the restart, shows the AppRecovery software has been removed.

I’ve also encountered a situation where the software uninstallation failed because User Account Control was enabled as indicated below. In such a scenario, I ran Powershell in Administrator mode before successfully uninstalling the software.