As a full-stack developer and Linux professional, I utilize PowerShell daily to automate tasks and manage my Windows systems. One incredibly useful feature is the ability to uninstall software directly from the command line using PowerShell. In this comprehensive guide, I‘ll walk through the various methods to uninstall programs with PowerShell.
Prerequisites
Before uninstalling software with PowerShell, ensure the following:
- PowerShell 5.0 or newer is installed
- You have administrative privileges on the machine
- The software was installed originally with an installer that supports uninstall
If the software is portable or was manually extracted, using the uninstall commands may not work properly.
Finding Installed Software
The first step is identifying what software is already installed that you wish to remove. PowerShell offers several handy commands for this:
Get-Package
The Get-Package cmdlet shows all software registered with the PackageManagement system. This includes programs installed via package managers like Chocolatey, MSI installers, etc.
Get-Package
You can filter further by provider, name, or other properties.
Get-WmiObject
To see legacy Win32 applications as well, use Get-WmiObject to access the Win32_Product WMI class:
Get-WmiObject -Class Win32_Product | Select-Object -Property Name
Get-ItemProperty
Finally, check the registry uninstall keys, which enumerate most installed software:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName
Uninstalling Software
Once you‘ve identified the software to remove, utilize one of the following uninstall methods:
Uninstall-Package
The simplest approach is to use the Uninstall-Package cmdlet. Pass the exact package name from Get-Package to uninstall it cleanly:
Uninstall-Package -Name PuTTY
You can force uninstalls with the -Force parameter to ignore dependencies and skip confirmation prompts.
Standard Uninstall String
Most traditional MSI or executable installers register an uninstall string in the registry. We can invoke these to trigger the regular add/remove programs uninstall workflow:
$UninstallString = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.DisplayName -like "*PuTTY*"}).UninstallString
Start-Process $UninstallString -Wait
This technique parses the registry, finds the desired software‘s uninstall string value, and executes it. The -Wait parameter pauses the PowerShell session until the launched process finishes.
Remove-WmiObject
For legacy Win32 applications, we can tap into WMI and simply tell it to remove the product:
$Application = Get-WmiObject -Class Win32_Product | Where {$_.Name -like "*PuTTY*"}
$Application.Uninstall()
Here we lookup the product via WMI filters, store it in a variable, and run the Uninstall() method to initiate removal.
Verifying Success
After running the uninstall command, verify the software no longer appears in your Get-Package, Get-WmiObject, or registry uninstall key queries. You may also need to check the original install directory and remove any remaining files manually.
Finally, reboot your computer to clear out any lingering registry entries or service connections.
Troubleshooting Failed Uninstalls
If an uninstall fails or the software still appears as installed, try the following troubleshooting steps:
- Re-run the uninstall command with -Force or other override parameters
- Use a 3rd party cleaner tool to purge all related registry entries
- Manually delete any leftover files or folders from the install path
- Research the specific uninstall error for solutions if available
- Use Install-Package -Force to repair the package then uninstall again
Sometimes uninstalls can fail if certain prerequisites like Visual C++ libraries are missing. Reinstalling these first may allow the uninstall to finish properly.
Conclusion
In closing, PowerShell provides administrators great flexibility to uninstall software cleanly and automation from the command line. Knowing these techniques can help remove unwanted, troublesome, or outdated programs quickly across many Windows systems. As with any major system change though, be sure to have good backups in place first!
Let me know in the comments if you have any other useful PowerShell uninstall tricks to share!


