Skip to content

install-github-cli

Installs GitHub CLI

#requires -version 5.1

try {
	"⏳ Installing GitHub CLI..."
	$stopWatch = [system.diagnostics.stopwatch]::startNew()

	if ($IsMacOS) {
		& brew install gh
	} elseif ($IsLinux) {
		& sudo apt install gh
	} else {
		& winget install --id GitHub.cli
		if ($lastExitCode -ne 0) { throw "Installation of GitHub CLI failed, maybe it's already installed." }
	}
	[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
	"✅ GitHub CLI installed successfully in $($elapsed)s - to authenticate execute: 'gh auth login'"
	exit 0
} catch {
throw
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.