Skip to content

Instantly share code, notes, and snippets.

@andre-f-paggi
Last active July 8, 2026 23:45
Show Gist options
  • Select an option

  • Save andre-f-paggi/2af460027ffb98608b3c39dc81fc2823 to your computer and use it in GitHub Desktop.

Select an option

Save andre-f-paggi/2af460027ffb98608b3c39dc81fc2823 to your computer and use it in GitHub Desktop.
dotfiles fresh-machine bootstrap prelude (Windows): install git+gh, auth, run install.ps1
# dotfiles fresh-machine bootstrap prelude (Windows).
#
# Run from an ELEVATED PowerShell:
# irm https://gist.github.com/andre-f-paggi/2af460027ffb98608b3c39dc81fc2823/raw | iex
#
# Installs git + GitHub CLI straight from their public release installers (works
# even where winget is absent, e.g. Windows Sandbox / fresh Win10 / Server), logs
# in to gh, then fetches and runs the (private) dotfiles install.ps1. install.ps1
# provisions winget itself and hands off to the modular bootstrap. Idempotent.
#
# ARM64: swap 'windows_amd64.msi' -> 'windows_arm64.msi' and the Git '-64-bit.exe'
# asset -> the '-arm64.exe' one.
Set-ExecutionPolicy -Scope Process Bypass -Force
$ErrorActionPreference = 'Stop'
$ua = @{ 'User-Agent' = 'dotfiles' }
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Host 'Installing Git for Windows ...'
$g = Invoke-RestMethod https://api.github.com/repos/git-for-windows/git/releases/latest -Headers $ua
$gExe = ($g.assets | Where-Object { $_.name -match '^Git-.*-64-bit\.exe$' }).browser_download_url
Invoke-WebRequest $gExe -OutFile "$env:TEMP\git.exe" -UseBasicParsing
Start-Process "$env:TEMP\git.exe" -ArgumentList '/VERYSILENT /NORESTART /NOCANCEL /SP-' -Wait
}
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
Write-Host 'Installing GitHub CLI ...'
$rel = Invoke-RestMethod https://api.github.com/repos/cli/cli/releases/latest -Headers $ua
$msi = ($rel.assets | Where-Object { $_.name -match 'windows_amd64\.msi$' }).browser_download_url
Invoke-WebRequest $msi -OutFile "$env:TEMP\gh.msi" -UseBasicParsing
Start-Process msiexec.exe -ArgumentList "/i `"$env:TEMP\gh.msi`" /quiet /norestart" -Wait
}
# Pick up the freshly installed tools in this session.
$env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' +
[Environment]::GetEnvironmentVariable('Path', 'User')
gh auth status *> $null
if ($LASTEXITCODE -ne 0) { gh auth login }
# Fetch and run the private install.ps1 (raw curl 404s on a private repo).
& ([scriptblock]::Create((gh api repos/andre-f-paggi/dotfiles/contents/install.ps1 -H "Accept: application/vnd.github.raw" | Out-String)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment