Skip to content

Instantly share code, notes, and snippets.

@tabs-not-spaces
Created March 15, 2019 07:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tabs-not-spaces/a6d920dbbc2d2ca1302cc63d9b159760 to your computer and use it in GitHub Desktop.
Save tabs-not-spaces/a6d920dbbc2d2ca1302cc63d9b159760 to your computer and use it in GitHub Desktop.
Install the latest version of chrome - every time. without fail.
try {
Write-Host "downloading installer.."
$chromeUri = "https://dl.google.com/chrome/install/latest/chrome_installer.exe"
$bitsJob = Start-BitsTransfer -Source $chromeUri -Destination "$env:Temp\$(split-path $chromeUri -leaf)"
if (Test-Path -Path "$env:Tempchrome_installer.exe") {
Write-Host "Installer downloaded successfully..`nInstalling application"
$proc = Start-Process -FilePath "$env:Tempchrome_installer.exe" -ArgumentList "/silent /install" -Wait
$fileDetectPath = "${env:ProgramFiles(x86)}\Google\Chrome\Application\Chrome.exe"
Write-Host "Looking for installation files: $fileDetectPath.."
if (Test-Path -Path "$fileDetectPath") {
Write-Host "Application files detected after installation.."
}
else {
Throw "Application files not detected after installation.."
}
}
else {
throw "Installer not found after download.."
}
}
catch {
$errorMsg = $_.Exception.Message
}
finally {
if ($errorMsg) {
Write-Warning $errorMsg
Throw $errorMsg
}
else {
Write-Host "Installation completed successfully.."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment