Skip to content

Instantly share code, notes, and snippets.

@Snaver

Snaver/Detect.ps1

Last active Apr 19, 2021
Embed
What would you like to do?
Google Chrome Uninstaller - PowerShell (Local install)
# Based on https://sccmentor.com/2021/01/11/using-proactive-remediations-to-remove-google-chrome/
# Thank you.
try
{
$chromeInstalled = Test-Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
if ($chromeInstalled -eq 'True') {
Write-Host "Google Chrome is installed locally"
exit 1
}
else {
#No remediation required
Write-Host "Google Chrome is not installed locally"
exit 0
}
}
catch {
$errMsg = $_.Exception.Message
Write-Error $errMsg
# exit 1
}
# $Chrome = Get-ChildItem -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match $($AppName)}
# $Chrome.UninstallString
$chromeInstalled = (Get-Item (Get-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe' -ErrorAction SilentlyContinue).'(Default)').VersionInfo
$ChromeVersion = $chromeInstalled.ProductVersion
$Installer = "$env:LOCALAPPDATA\Google\Chrome\Application\$ChromeVersion\Installer\setup.exe"
$Arguements = "--uninstall --force-uninstall"
Start-Process $Installer $Arguements -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment