-
-
Save kurokikaze/350fe1713591641b3b42 to your computer and use it in GitHub Desktop.
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec |
@STiG-1
Yeah, I've found that url too. It installs x86 which will get upgraded to x64 later on of the OS is actually x64.
I don't have access to internet on my windows server. How can I use this script then?
I don't have access to internet on my windows server. How can I use this script then?
You need to download the offline installer for Chrome. Store it on some internal file share and copy down during install or add it into the image, etc
For something a little more sophisticated, here is a powershell function you can run. it also uses the latest version, not a specific version. i also used -PassThru to get the explicit process i started.
function Install-Chrome
{
$LocalTempDir = $env:TEMP;
$ChromeInstaller = "ChromeInstaller.exe";
$url='http://dl.google.com/chrome/install/latest/chrome_installer.exe';
$output="$LocalTempDir\$ChromeInstaller"
try {
(new-object System.Net.WebClient).DownloadFile($url, $output);
$p = Start-Process $output -ArgumentList "/silent","/install" -PassThru -Verb runas;
while (!$p.HasExited) { Start-Sleep -Seconds 1 }
Write-Output ([PSCustomObject]@{Success=$p.ExitCode -eq 0;Process=$p})
} catch {
Write-Output ([PSCustomObject]@{Success=$false;Process=$p;ErrorMessage=$_.Exception.Message;ErrorRecord=$_})
} finally {
Remove-Item "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose
}
}
Install-Chrome
thank you so much. This solution works like a charm. Is there a way by which i can extract the chrome version from "http://dl.google.com/chrome/install/latest/chrome_installer.exe"
If you get an error like Invoke-WebRequest : The underlying connection was closed
, your system may be configured with strong TLS ciphers by default. Change them in the current powershell environment by running [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Thanks to @eesheesh , I could install chrome in Run Dialog. Here's slightly improved version which reduces download time by removing progress bar. ( https://stackoverflow.com/a/43477248 )
PowerShell -Command "& {$P=$env:TEMP+'\chrome_installer.exe';$ProgressPreference='SilentlyContinue';IWR 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' -OutFile $P;SAPS -FilePath $P -Args '/silent /install' -Verb RunAs -Wait;DEL $P}"
"http://dl.google.com/chrome/install/latest/chrome_installer.exe" This is not downloading the latest version of Chrome. Does anyone know the reason?
❤️ @nicolaigj
Thanks @kyungjaepark! I've put this in a dedicated website, to make it easy for folks to quickly install Chrome/Firefox on a new machine, without having to type in the command: https://insta.llc (works with http://insta.llc without redirects as well, for folks installing versions of Windows that complain about HTTPS).
$uri = "https://dl.google.com/chrome/install/latest/chrome_installer.exe";
$path = "$PSScriptRoot\ChromeSetup.exe";
Invoke-WebRequest -Uri $uri -OutFile $path;
Start-Process $path /install -NoNewWindow -Wait;
Remove-Item $path;
Thanks @kyungjaepark! I've put this in a dedicated website, to make it easy for folks to quickly install Chrome/Firefox on a new machine, without having to type in the command: https://insta.llc (works with http://insta.llc without redirects as well, for folks installing versions of Windows that complain about HTTPS).
This is amazing work, thank you so much! If I could only find something similar for Adobe Reader my life would be complete.
@o-l-a-v Using this code, it downloads the online installer, and the 64-bit version is downloaded and installed:
$uri = "https://dl.google.com/chrome/install/latest/chrome_installer.exe" $path = "$PSScriptRoot\ChromeSetup.exe" Invoke-WebRequest -Uri $uri -OutFile $path Start-Process $path /install -NoNewWindow -Wait Remove-Item .\ChromeSetup.exe