Install Github CLI
Checklist
# Define the URL to fetch the latest release information
$latestReleaseUrl = "https://api.github.com/repos/cli/cli/releases/latest"
# Define the path where the file will be saved
$outputDir = "C:\psinstalls\"
$outputFile = "$outputDir\gh_latest_windows_amd64.msi"
# Create the directory if it doesn't exist
if (-not (Test-Path -Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir -Force
}
# Fetch the latest release information
$latestRelease = Invoke-RestMethod -Uri $latestReleaseUrl
# Extract the download URL for the Windows MSI asset
$asset = $latestRelease.assets | Where-Object { $_.name -match "windows_amd64.msi" }
$downloadUrl = $asset.browser_download_url
# Download the file
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile
# Verify download
if (Test-Path -Path $outputFile) {
Write-Output "Download completed successfully: $outputFile"
# Install the downloaded MSI
Start-Process msiexec.exe -ArgumentList '/i $outputFile /qn' -Wait
# Verify installation
$versionCheck = gh --version
if ($versionCheck) {
Write-Output "Installation completed successfully: $(gh --version)"
} else {
Write-Output "Installation failed."
}
} else {
Write-Output "Download failed."
}
Install Github CLI
Checklist