Created
March 9, 2026 03:34
-
-
Save sjwaight/1b2143ad5abfee468086d0889d850dfd to your computer and use it in GitHub Desktop.
PowerShell script to download latest stable Cilium CLI for Windows and install it.
This file contains hidden or 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
| # PowerShell version of Cilium CLI installation. | |
| # *nix version here: https://github.com/cilium/cilium-cli | |
| # Converted using Copilot, validated by a human :D | |
| # Requires Administrative privileges to run end-to-end | |
| $ErrorActionPreference = "Stop" | |
| # Get latest stable Cilium CLI version | |
| $CILIUM_CLI_VERSION = (Invoke-RestMethod -Uri "https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt").Trim() | |
| # Set OS/arch for Windows release asset naming | |
| $GOOS = "windows" | |
| switch ($env:PROCESSOR_ARCHITECTURE.ToUpper()) { | |
| "AMD64" { $GOARCH = "amd64" } | |
| "ARM64" { $GOARCH = "arm64" } | |
| default { throw "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE" } | |
| } | |
| $archive = "cilium-windows-$GOARCH.zip" | |
| $checksum = "$archive.sha256sum" | |
| $baseUrl = "https://github.com/cilium/cilium-cli/releases/download/$CILIUM_CLI_VERSION" | |
| # Download archive + checksum | |
| Invoke-WebRequest -Uri "$baseUrl/$archive" -OutFile $archive | |
| Invoke-WebRequest -Uri "$baseUrl/$checksum" -OutFile $checksum | |
| # Verify SHA256 | |
| $expected = (Get-Content $checksum | Select-Object -First 1).Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)[0].ToLower() | |
| $actual = (Get-FileHash -Path $archive -Algorithm SHA256).Hash.ToLower() | |
| if ($actual -ne $expected) { | |
| throw "SHA256 mismatch for $archive. Expected $expected, got $actual" | |
| } | |
| # Install location (admin required for Program Files) | |
| $installDir = "$env:ProgramFiles\cilium" | |
| New-Item -ItemType Directory -Path $installDir -Force | Out-Null | |
| # Extract .zip and install cilium.exe | |
| $tempDir = Join-Path $env:TEMP "cilium-extract-$([guid]::NewGuid().ToString('N'))" | |
| New-Item -ItemType Directory -Path $tempDir -Force | Out-Null | |
| Expand-Archive -Path $archive -DestinationPath $tempDir -Force | |
| $ciliumExe = Join-Path $tempDir "cilium.exe" | |
| if (-not (Test-Path $ciliumExe)) { | |
| throw "cilium.exe not found in extracted archive." | |
| } | |
| Move-Item -Path $ciliumExe -Destination (Join-Path $installDir "cilium.exe") -Force | |
| Remove-Item -Path $tempDir -Recurse -Force | |
| # Optional: add to user PATH if not already there | |
| if (($env:Path -split ';') -notcontains $installDir) { | |
| [Environment]::SetEnvironmentVariable( | |
| "Path", | |
| [Environment]::GetEnvironmentVariable("Path", "User") + ";$installDir", | |
| "User" | |
| ) | |
| Write-Host "Added $installDir to your user PATH. Restart terminal to pick it up." | |
| } | |
| # Cleanup | |
| Remove-Item $archive, $checksum -Force | |
| Write-Host "Installed Cilium CLI to $installDir" | |
| Write-Host "Run: cilium version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment