Uninstall All versions of Chrome

Hi Awesome PS People,

I want to Uninstall all versions of chrome present in environment before installing new version of Chrome in the environment.
What I am trying to do is I am querying machine at run time to give me installed GUID’s of Chrome and then match it with list of ver and then uninstall it accordingly using nested if statements.
But I am hitting a bottleneck here as I can’ t get array to compare and yield results any suggestions. If you have a better idea to do this, please suggest as well.

Hi.
Have a look at remove-Msiapplication
You could just do something like remove-Msiapplication -Name ‘google chrome’

Sorry for

1 Like

You can also do this… This works for any MSI application.

    ## uninstall all previous versions of bricsCAD before continuing
    $GoogleCHrome = Get-InstalledApplication -Name 'Google Chrome' | Select -ExpandProperty UninstallString

    if ($GoogleCHrome) {
        foreach ($item in $GoogleCHrome) 
        {
            $ChomeProductCode = $item -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
            $ChomeProductCode = $ChomeProductCode.Trim()
            Execute-MSI -Action 'Uninstall' -Path $ChomeProductCode -Parameters '/QN' -ContinueOnError $true
        }
    }  

But know that the Google Chrome enterprise installer will just update, not matter what version is currently installed.
So not really required to uninstall first…

1 Like

Yea, Aldin, That is exactly my challenge is, that uninstall chrome completely like ver and updater and all completely and then install my chrome enterprise ver 80.0.132.
Your script actually helped me to uninstall chrome on my machine, but when installing it again, gave me error on some machines like chrome msi installer ver is higher than the ver installed, not sure if that is depended on the fact that chrome enterprise actually has win installer different than chrome ver installed on machines.

If do a quick check of wmic product select query to get -name “Google” we can see that chrome will show chrome installer ver and its win installer ver with google updater ver.

Google Updater will sometimes uninstall with google chrome guid’s but sometimes chrome’s win installer ver guid does not uninstall, which actually poses issue when installing chrome on a machine.

Then I have to use MS Uninstaller for stuck installation tools to remove product msi and guid;'s from affected machines to fix the issue.

What I am trying to build is a silent version for a single application tool which can do this task for me so that we can avoid such issues with stuck installations.

Hope to get your input on same.

Thanks

Hi _RichardKnight,

I tried using your option but it gave me “” [03-05-2020 16:09:45.564] [Post-Uninstallation] [Remove-MSIApplications] :: Skipping removal of application [Google Chrome] because uninstall string [] does not match “msiexec”.""

This should do the trick…

It will uninstall ALL installed Google Chrome browsers, including the Update Helper if it is not being uninstalled by the Chrome uninstaller.

It will uninstall Chrome installed with EXE as well as the Enterprise installer.

$GChromeInstalled = Get-InstalledApplication -Name 'Google Chrome' | Select -ExpandProperty UninstallString

#Normally there can only be one Google Chrome installed, but just in case something is off, this will uninstall them all
if ($GChromeInstalled.Count -gt 1) {
    foreach ($item in $GChromeInstalled) {
        if ($item -match 'setup.exe') {
            $UninstallString = $item.Split('"')[1]
            Execute-Process -Path "$UninstallString" -Parameters "--uninstall --system-level --multi-install --force-uninstall" -ContinueOnError $true
        }
        elseif ($item -match '{*}') {
            $GChromeProductCode = $item -Replace "msiexec.exe", "" -Replace "/I", "" -Replace "/X", ""
            $GChromeProductCode = $GChromeProductCode.Trim()
            Execute-MSI -Action 'Uninstall' -Path $GChromeProductCode -Parameters '/QN'
        }
    }
}
else {
    if ($GChromeInstalled -match 'setup.exe') {
        $UninstallString = $GChromeInstalled.Split('"')[1]
        Execute-Process -Path "$UninstallString" -Parameters "--uninstall --system-level --multi-install --force-uninstall" -ContinueOnError $true
    }
    elseif ($GChromeInstalled -match '{*}') {
        $GChromeProductCode = $GChromeInstalled -Replace "msiexec.exe", "" -Replace "/I", "" -Replace "/X", ""
        $GChromeProductCode = $GChromeProductCode.Trim()
        Execute-MSI -Action 'Uninstall' -Path $GChromeProductCode -Parameters '/QN'
    }
}

#Uninstall Update Helper if it's installed
#Filtering for Google only because other Chromium Browsers use the same tool but in a different location (e.g. Brave Browser)
$GUpdateHelper = Get-InstalledApplication -Name 'Google Update Helper' | where { $_.InstallSource -match "Google" } | Select -ExpandProperty UninstallString

if ($GUpdateHelper -match 'GoogleUpdate.exe') {
    if (Test-Path -Path "$envProgramFiles\Google\Update\GoogleUpdate.exe") {
        Execute-Process -Path "$envProgramFiles\Google\Update\GoogleUpdate.exe" -Parameters "/uninstall"
    }
    elseif (Test-Path -Path "$envProgramFilesX86\Google\Update\GoogleUpdate.exe") {
        Execute-Process -Path "$envProgramFilesX86\Google\Update\GoogleUpdate.exe" -Parameters "/uninstall"
    }
}
elseif ($GUpdateHelper -match '{*}') {
    $GUpdateHelperProductCode = $GUpdateHelper -Replace "msiexec.exe", "" -Replace "/I", "" -Replace "/X", ""
    $GUpdateHelperProductCode = $GUpdateHelperProductCode.Trim()
    Execute-MSI -Action 'Uninstall' -Path $GUpdateHelperProductCode -Parameters '/QN'
}

# fail safe, if Update Helper didn't uninstall above
if (Test-Path -Path "$envProgramFiles\Google\Update\GoogleUpdate.exe") {
    Execute-Process -Path "$envProgramFiles\Google\Update\GoogleUpdate.exe" -Parameters "/uninstall"
}
elseif (Test-Path -Path "$envProgramFilesX86\Google\Update\GoogleUpdate.exe") {
    Execute-Process -Path "$envProgramFilesX86\Google\Update\GoogleUpdate.exe" -Parameters "/uninstall"
}
1 Like

HI Aldin,

I know your script can help me, this maybe some issue with machine in my environment only.
Can you help me to enable logging on every step so that I can know where exactly is calling what and doing what.

I tried running your script in a script block it just says :

but it never uninstalls any google chrome application on my machine.
Any help will be appreciated.

Logging is enabled by default.
In my environment I changed the path for the log files to be all in the same location.
You can do the same by editing the Config file of the toolkit
“\Toolkit\AppDeployToolkit\AppDeployToolkitConfig.xml”

Check this to see where log files are written to or change to something else if you don’t like it:
<Toolkit_LogPath>C:\Logfiles</Toolkit_LogPath>

You can add your own custom log entries for each step with:
Write-Log "Starting “Your text” -Source “YourName”

However, each step that the toolkit does is logged by default. Your custom log entries may help to quickly identify where your script is at.

The -Source parameter is optional, but entering here something (like your name) will help you to easily find the entry in the log file when viewing it in CMTrace.
You’ll find whatever you typed in there as the “Component” in CMTrace.

That being said…
The script does uninstall all chrome versions on my test devices. So I’m pretty sure it works.

Hi Aldin,

here are the logs which I found after your suggestion:

MSI (s) (68:FC) [15:15:54:699]: User policy value ‘DisableRollback’ is 0
MSI (s) (68:FC) [15:15:54:699]: Machine policy value ‘DisableRollback’ is 0
MSI (s) (68:FC) [15:15:54:699]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (68:FC) [15:15:54:699]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (68:FC) [15:15:54:699]: Note: 1: 2265 2: 3: -2147287035
MSI (s) (68:FC) [15:15:54:699]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (68:FC) [15:15:54:699]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (s) (68:FC) [15:15:54:699]: Post-install cleanup: removing installer file ‘C:\WINDOWS\Installer\4ac78fdf.msi’
MSI © (00:30) [15:15:54:699]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI © (00:30) [15:15:54:699]: MainEngineThread is returning 0
=== Verbose logging stopped: 06-03-2020 15:15:54 ===

When I have gone and checked this location can’t find this “4ac78fdf.msi” at installer location.
I tried restarting machine as well, it still does not work.

I have kept the code in pre-installation stage, should I be keeping it at some other location? Please suggest.

Google Chrome MSI Installer has two GUID’s one is Win Installer Guid and other is google Chrome guid, when you check it with wmic product select query command for ‘google’ you can find both guid;s which you can’t find easily on your machine, Which is causing issues in clean installation of chrome on machine, because if you clean Google Chrome msi you would still have or chances of leaving old guid’s of win installer associated with chrome.

The script checks the uninstall string associated with the installed product, whether it’s an MSI or the EXE installer and runs the appropriate uninstaller depending of how it was installed. So that won’t be a problem.

I’m not sure what the issue now is to be honest. Above log file is incomplete.

Does the script get stuck?
You have the Verbose log file from the MSI (which I suppose above log is from) and you have the log file of the toolkit itself.
In the PSADT log file you can see each action it’s executing.

Hi,

What you have to do is querying the HKLM\Software\Microsoft\Windows\Currentversion\uninstall for the displayname with Google Chrome. The get the uninstall commandline. No need for a list.

Thanks,

Thanks all for all the help :slight_smile:
this issue is now fixed.