55 lines
2.2 KiB
PowerShell
55 lines
2.2 KiB
PowerShell
# =============================================================================
|
|
# 00-install-gcloud.ps1 (Windows)
|
|
# Installs the Google Cloud CLI (gcloud) on Windows.
|
|
# Run this once in an elevated PowerShell prompt before doing anything else.
|
|
#
|
|
# Linux users: run GCR/scripts/00-install-gcloud.sh instead.
|
|
# =============================================================================
|
|
#Requires -Version 5.1
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
Write-Host ">>> Installing Google Cloud CLI on Windows..."
|
|
Write-Host ""
|
|
|
|
# ── Try winget first (available on Windows 10 1709+ / Windows 11) ────────────
|
|
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
|
Write-Host ">>> winget found — installing Google Cloud SDK via winget..."
|
|
winget install --id Google.CloudSDK --accept-source-agreements --accept-package-agreements
|
|
Write-Host ""
|
|
Write-Host ">>> gcloud installed via winget."
|
|
Write-Host " Close and reopen PowerShell so PATH changes take effect."
|
|
}
|
|
# ── Fallback: download the official Windows installer ────────────────────────
|
|
else {
|
|
Write-Host ">>> winget not available — downloading the official installer..."
|
|
Write-Host ""
|
|
|
|
$InstallerUrl = "https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe"
|
|
$InstallerPath = "$env:TEMP\GoogleCloudSDKInstaller.exe"
|
|
|
|
Write-Host " Downloading from: $InstallerUrl"
|
|
Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath -UseBasicParsing
|
|
|
|
Write-Host " Launching installer..."
|
|
Write-Host " Follow the on-screen prompts. Make sure 'Add gcloud to PATH' is checked."
|
|
Write-Host ""
|
|
Start-Process -FilePath $InstallerPath -Wait
|
|
Remove-Item $InstallerPath -Force
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host ">>> Verifying installation..."
|
|
try {
|
|
$version = & gcloud version 2>&1 | Select-Object -First 1
|
|
Write-Host " $version"
|
|
Write-Host ""
|
|
Write-Host ">>> gcloud is installed."
|
|
} catch {
|
|
Write-Host " gcloud not found on PATH yet."
|
|
Write-Host " Close and reopen PowerShell, then run: gcloud version"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host ">>> Next step: run GCR\scripts\01-login.ps1"
|