Created
March 15, 2019 07:27
-
-
Save tabs-not-spaces/a6d920dbbc2d2ca1302cc63d9b159760 to your computer and use it in GitHub Desktop.
Install the latest version of chrome - every time. without fail.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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