Yesterday’s post Download and Install Latest Mozilla Firefox about evergreen URLs spiked quite some engagement in the community on Twitter sharing their Git resources.
Aaron Parker shared his Function on how to read Google’s JSON file to find the latest version. This was the missing piece of the puzzle to make my Google Chrome Enterprise installation script evergreen.
You see even with Google’s URL to their latest version it wasn’t possible for me to grab the version number. Which means I needed to do stuff manually or simple download and delete each and every time.
This might makes sense in some case, but in terms of VMware Tools (working on it) it’s very unefficient, unstable and waste of time to download each and every time. Not to mention what happens when the script runs about the same time on 2-3 VMs.
In my Infrastructure as Code deployment I deploy 14 VM’s in 30 minutes. If I would download each and every time that would be stupid. IMHO my scripts will only be published when they’re true evergreen. Another benefit is that you get a media libary where you can easily rollback if lastest release is unstable. Enjoy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# Get latest Google Chrome versions from public JSON feed - Aaron Parker # https://gist.github.com/aaronparker/30bbc9ec61755e1ad86a8e4292fba98e Function Get-ChromeVersion { [CmdletBinding()] Param ( [Parameter(Mandatory = $False)] [string] $Uri = "https://omahaproxy.appspot.com/all.json", [Parameter(Mandatory = $False)] [ValidateSet('win', 'win64', 'mac', 'linux', 'ios', 'cros', 'android', 'webview')] [string] $Platform = "win", [Parameter(Mandatory = $False)] [ValidateSet('stable', 'beta', 'dev', 'canary', 'canary_asan')] [string] $Channel = "stable" ) # Read the JSON and convert to a PowerShell object. Return the current release version of Chrome $chromeVersions = (Invoke-WebRequest -uri $Uri).Content | ConvertFrom-Json $output = (($chromeVersions | Where-Object { $_.os -eq $Platform }).versions | ` Where-Object { $_.channel -eq $Channel }).current_version Write-Output $output } # PowerShell Wrapper for MDT, Standalone and Chocolatey Installation - (C)2015 xenappblog.com # Example 1: Start-Process "XenDesktopServerSetup.exe" -ArgumentList $unattendedArgs -Wait -Passthru # Example 2 Powershell: Start-Process powershell.exe -ExecutionPolicy bypass -file $Destination # Example 3 EXE (Always use ' '): # $UnattendedArgs='/qn' # (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode # Example 4 MSI (Always use " "): # $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp" # (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode Write-Verbose "Setting Arguments" -Verbose $StartDTM = (Get-Date) $Vendor = "Google" $Product = "Chrome Enterprise" $Version = $(Get-ChromeVersion) $PackageName = "googlechromestandaloneenterprise64" $InstallerType = "msi" $Source = "$PackageName" + "." + "$InstallerType" $LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log" $LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log" $Destination = "${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 NOGOOGLEUPDATEPING=1 /qn /liewa $LogApp" $url = "https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi" $ProgressPreference = 'SilentlyContinue' Start-Transcript $LogPS if( -Not (Test-Path -Path $Version ) ) { New-Item -ItemType directory -Path $Version } CD $Version Write-Verbose "Downloading $Vendor $Product $Version" -Verbose If (!(Test-Path -Path $Source)) { Invoke-WebRequest -Uri $url -OutFile $Source } Else { Write-Verbose "File exists. Skipping Download." -Verbose } Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode Write-Verbose "Customization" -Verbose sc.exe config gupdate start= disabled sc.exe config gupdatem start= disabled Unregister-ScheduledTask -TaskName GoogleUpdateTaskMachineCore -Confirm:$false Unregister-ScheduledTask -TaskName GoogleUpdateTaskMachineUA -Confirm:$false Write-Verbose "Stop logging" -Verbose $EndDTM = (Get-Date) Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose Stop-Transcript |
Can you make it a regular Chrome install and not enterprise?