You can uninstall Google Chrome using PowerShell with a specific set of commands that leverage Windows Management Instrumentation (WMI). Here's how:
Steps to Uninstall Chrome using PowerShell
Here's a breakdown of the PowerShell commands to uninstall Chrome, explained step-by-step:
-
Identify Chrome using WMI: The first step is to identify the Chrome installation using the
Get-WmiObject
cmdlet. This command queries theWin32_Product
WMI class to find the application named "Google Chrome."$Chrome = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "Google Chrome*" }
-
Iterate through the results: If Chrome is found, the next step is to iterate through each instance (although typically there's only one).
foreach ($Product in $Chrome) {
-
Uninstall Chrome: Within the loop, the
Uninstall()
method is called on each found Chrome instance. This initiates the uninstallation process.$Product.Uninstall() }
-
Confirmation Message: After attempting to uninstall, display a confirmation message to the user.
Write-Output "Google Chrome successfully uninstalled"
Complete PowerShell Script for Uninstalling Chrome
Here's the complete script:
$Chrome = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "Google Chrome*" }
foreach ($Product in $Chrome) {
$Product.Uninstall()
}
Write-Output "Google Chrome successfully uninstalled"
To use this script:
- Open PowerShell as an administrator.
- Copy and paste the script into the PowerShell window.
- Press Enter.
Troubleshooting
- Permissions: Ensure you are running PowerShell as an administrator. Otherwise, the script might fail due to insufficient permissions to uninstall software.
- Chrome in Use: If Chrome is running, the uninstallation might fail. Close Chrome and any related processes (e.g., Chrome Helper) before running the script.
- WMI Issues: Problems with WMI can prevent the script from functioning correctly. You can try restarting the WMI service.
Why Use PowerShell to Uninstall?
PowerShell offers a command-line approach, which can be useful for:
- Automation: You can include this script in larger automation workflows.
- Remote Uninstallation: With proper configuration, you can use PowerShell to uninstall Chrome on remote machines.
- Scripted Solutions: For system administrators, PowerShell scripts provide a consistent and repeatable method for software management.