问题
This is based on my previous question where I use the script in the accepted answer: https://stackoverflow.com/a/51933920/3737177
I manage to download the exe via a ps1 script, but it seems it is corrupt. If I compare it to a file downloaded through the browser they look the same. Same file version, same SHA, but the one downloaded with a script gets an error:
If I try to execute it from the script ".\ChromeStandaloneSetup.exe /install" there is some more information, but this doesn't help either:
Any ideas, why this exe is corrupt when downloaded through PowerShell? Or rather how to fix it?
I tried it with PowerShell V4.0 and 5.1, so the Invoke-WebRequest is used.
回答1:
I was able to reproduce and experience the same error. Even if I manually download the installer from the URL provided in that solution.
When I download the .msi from https://enterprise.google.com/chrome/chrome-browser/ using BITS (which is much faster than Invoke-WebRequest), I am able to silently install Google Chrome.
$uri = "https://dl.google.com/chrome/install/googlechromestandaloneenterprise64.msi"
if (-not $PSScriptRoot) {
$PSScriptRoot = Split-Path -Parent -Path $script:MyInvocation.MyCommand.Definition
}
$outFile = "$PSScriptRoot\googlechromestandaloneenterprise64.msi"
Start-BitsTransfer -Source $uri -Destination $outFile
Start-Process -FilePath $outFile -Args "/qn" -Wait
来源:https://stackoverflow.com/questions/52035868/downloaded-chromestandalonesetup-exe-with-powershell-is-corrupt