Searching for the perfect web browser is like looking for a life partner. Yup, hear us out for a minute. For both, you need to make sure your goals are aligned (compatibility, good UX). You need them to be supportive and dependable (load time, security, privacy). You want to grow together, learn and explore together (extensions). Support each other when something goes wrong (updates, patches, games to play while you’re waiting for the WIFI to come back). Of course, physical attraction doesn’t hurt either…
And since we’re all in on this metaphor, when you finally find the one, you never want to let it go. You want to shout it from the rooftops, share the news with everyone you know!
Well, for all you Google Chrome lovers, this is the script for you!
You can check whether there is a version of chrome already installed on your end user devices and if not, install the enterprise version from afar (because everyone should be using your favorite browser, right?)
The script follows a series of silent validation checks, so it will install Chrome without informing the end user of any changes. If there is an error while the script is running, it will be recorded in an event log so you can see what went wrong.
Whether it was love at first browser, or a slow and steady connection, this script will give your customers the option to fall for Chrome as well.
The Script:
Atera does not guarantee the integrity, availability, security, virus-free, safety, lawfulness, non-infringement, rights’ status, or functionality of the scripts. The use of the shared scripts is at your own risk. Scripts are provided “AS IS”. *
$DestinationDir = "C:\Temp"
$LogFile = "C:\Temp\GoogleChromeDeploymentLog.log"
$TmpOb = New-Object System.Net.WebClient
$ERRORVal = $false
$currentVer=$null
$Detection-$false
$LatestVer = ((((Invoke-WebRequest -uri "https://omahaproxy.appspot.com/all.json" -UseBasicParsing).Content | ConvertFrom-Json) | Where-Object { $_.os -eq "win64" }).versions | `Where-Object { $_.channel -eq "Stable" }).current_version
function Chrome{
param ([string]$maintenance)
try{
try{
$FileChk=(Get-Item $DestinationDir+'\googlechromestandaloneenterprise64.msi' -ErrorAction Stop).Exists
if($fileChk){(Get-Item $DestinationDir+'\googlechromestandaloneenterprise64.msi').Delete()}
}catch [Exception]{}
$TmpOb.DownloadFile("https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi",$DestinationDir+'\googlechromestandaloneenterprise64.msi')
Write-Host "Download successful: "(Get-Date) | Out-File -FilePath $LogFile -Append
}catch [Exception]{
$ERRORVal = $true
Write-Host "An error occurred during download: "(Get-Date) | Out-File -FilePath $LogFile -Append
$_.Exception | Format-List -force | Out-File -FilePath $LogFile -Append}
if(!$ERRORVal){
try{
Write-Host "Initiating "$maintenance ":"(Get-Date) | Out-File -FilePath $LogFile -Append
$PObj = (Start-Process msiexec.exe -ArgumentList "/i $DestinationDir\googlechromestandaloneenterprise64.msi ALLUSERS=1 NOGOOGLEUPDATEPING=1 /qn /liewa+ $LogFile" -Wait -Passthru).ExitCode
}catch [exception]{}
}
}
if (!(Test-path $destinationdir)){
new-item -ItemType directory -Path C:\ -Name temp
}
if (Get-Item $LogFile -ErrorAction Ignore){
(Get-Item $LogFile).Delete()
}
New-item -ItemType File -Path C:\Temp -Name GoogleChromeDeploymentLog.log
try{
$Detection = ($null -ne (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" -ErrorAction Stop))
$currentVer=((Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe' -ErrorAction Stop).'(Default)').VersionInfo | Select-Object ProductVersion).ProductVersion
Write-Host "Detected existing installation with product version:"$currentVer" "(Get-Date) | Out-File -FilePath $LogFile -Append
}catch [Exception]{
Write-Host "An existing Google Chrome installation not identified on the System & proceeding to installation...: "(Get-Date) | Out-File -FilePath $LogFile -Append
chrome
}
Will this script also update Google Chrome to the latest version on my end-user devices?
If Google Chrome is already installed on the device, this script will not update it to the latest version. This script will output the version currently installed and add it to the log file. You can then update Chrome to the latest version.
If the device has a non-enterprise version of Google Chrome installed, will it still install the enterprise version?
In short, no. The script checks first whether a log file exists similar to: “C:\Temp\GoogleChromeDeploymentLog.log” If a similar log file does exist, the script deletes the log file. It then checks if the chrome.exe registry value exists. If the registry value does exist, (and it will if any previous version of Chrome is installed on the device), the script will stop and will output the current version of Chrome. You can then choose to update to the latest version of Chrome, delete the current version and install an enterprise version, or leave everything as is.
Technical Notes:
- Admin permissions needed to run this script.
- An internet connection is required to download the MSI package.
- You can find the event log (including error events) in the following file: C:\Temp\GoogleChromeDeploymentLog.log
Explore our shared script library
The all-in-one IT management platform that will take your IT operations to the next level!