trash-windows-scripts/Install Chrome in Windows P...

31 lines
1.1 KiB
Plaintext

# Script to install the latest version of Google Chrome
# Check if the script is running with administrator privileges
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Please run this script as Administrator!"
Break
}
# URL for the latest Chrome installer
$chromeUrl = "https://dl.google.com/chrome/install/latest/chrome_installer.exe"
$installerPath = "$env:TEMP\chrome_installer.exe"
Write-Host "Downloading Google Chrome..." -ForegroundColor Green
try {
# Download the installer
Invoke-WebRequest -Uri $chromeUrl -OutFile $installerPath -UseBasicParsing
Write-Host "Installing Google Chrome..." -ForegroundColor Green
# Install silently without user interaction
Start-Process -FilePath $installerPath -Args "/silent /install" -Wait
Write-Host "Google Chrome has been successfully installed!" -ForegroundColor Green
# Delete the installer file
Remove-Item $installerPath -Force
} catch {
Write-Host "Error during installation: $_" -ForegroundColor Red
}