Shared Script Library
GitHubLinkedInSponsor
  • Overview
  • Software
    • Installers
      • Bluebeam Revu
      • Browser Extension
      • Google Chrome
      • Microsoft Defender for Endpoint
      • Microsoft Office
      • Microsoft Teams
      • QuickBooks Desktop
    • Uninstallers
      • Browser Extension
  • Device Management
    • Backups
      • SQL Databases
      • Synology Active Backup
      • Windows Restore Point
    • Updates
      • Dell Command Update
      • Microsoft Office
      • Microsoft Store Applications
      • Windows Management Framework
      • Windows Updates
    • Misc
      • Reset Local Group Policy
Powered by GitBook
On this page
  • Overview
  • Script
  • Examples
  • Parameters

Was this helpful?

  1. Software
  2. Installers

Google Chrome

PowerShell script to silently install the latest version of Google Chrome.

PreviousBrowser ExtensionNextMicrosoft Defender for Endpoint

Last updated 7 months ago

Was this helpful?

Overview

Dev Insight: This script can be used as a template for performing basic download and installation of other simple msi installers.

This script downloads and installs the latest version of Google Chrome.

Prerequisites: This script has no prerequisites.


Script

Examples

.\InstallGoogleChrome.ps1

This example downloads and installs the latest version of Google Chrome.


Parameters

This script has no parameters.

Download Chrome Browser for Your Business - Chrome EnterpriseGoogle Chrome Enterprise
Logo
https://github.com/wise-io/scripts/blob/main/scripts/InstallGoogleChrome.ps1
<#
  .SYNOPSIS
    Installs Google Chrome
  .DESCRIPTION
    Downloads and installs the latest version of Google Chrome silently.
  .NOTES
    Author: Aaron J. Stevenson
#>

$DownloadURL = 'https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise.msi'
$Installer = Join-Path -Path $env:TEMP -ChildPath ($DownloadURL -Split '/')[-1]

function Get-InstallStatus {
  param(
    [Parameter(Mandatory = $true)]
    [String]$Name
  )

  $RegPaths = (
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
    'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
  )

  # Wait for registry to update
  Start-Sleep -Seconds 5

  $Program = Get-ChildItem -Path $RegPaths | Get-ItemProperty | Where-Object { $_.DisplayName -match $Name } | Select-Object
  if ($Program) { Write-Output "`nInstalled $Name [$($Program.DisplayVersion)]" }
  else { Write-Warning "`n$Name not detected." }
}

function Install-GoogleChrome {
  
  # Adjust download URL
  if ([Environment]::Is64BitOperatingSystem) { 
    $DownloadURL = $DownloadURL.Replace('.msi', '64.msi') 
  }
  
  # Installer Arguments
  $ArgumentList = @(
    '/i',
    "$Installer",
    '/quiet'
  )

  try {
    Write-Output "`nDownloading Google Chrome..."
    Invoke-WebRequest -Uri $DownloadURL -OutFile $Installer
    Write-Output 'Installing...'
    Start-Process -Wait msiexec -ArgumentList $ArgumentList
    Get-InstallStatus 'Google Chrome'
  }
  catch { 
    Write-Warning 'There was an issue installing Google Chrome.'
    Write-Warning $_
  }
  finally { 
    Remove-Item $Installer -Force -ErrorAction Ignore
    exit $LASTEXITCODE
  }
}

# Adjust PowerShell settings
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
if ([Net.ServicePointManager]::SecurityProtocol -notcontains 'Tls12' -and [Net.ServicePointManager]::SecurityProtocol -notcontains 'Tls13') {
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}

Install-GoogleChrome