# Installs fetch.exe (the Fetch Agent and CLI) on Windows: # irm https://fetch.nightroll.app/install.ps1 | iex # It downloads the Windows build from https://fetch.nightroll.app/download/, checks its SHA-256 against the release's # SHA256SUMS, installs it into %LOCALAPPDATA%\Programs\Fetch and adds that folder to your PATH. Rerun it to update. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $base = if ($env:FETCH_DOWNLOAD) { $env:FETCH_DOWNLOAD } else { 'https://fetch.nightroll.app/download' } $dest = Join-Path $env:LOCALAPPDATA 'Programs\Fetch' $sums = [Text.Encoding]::UTF8.GetString((Invoke-WebRequest "$base/SHA256SUMS" -UseBasicParsing).RawContentStream.ToArray()) $line = $sums -split "`n" | Where-Object { $_ -match '-windows-x86_64\.zip\s*$' } | Select-Object -First 1 if (-not $line) { throw 'fetch: the current release has no Windows build.' } $sha, $file = ($line.Trim() -split '\s+') $tmp = Join-Path ([IO.Path]::GetTempPath()) ("fetch-install-" + [Guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host "Downloading $file" Invoke-WebRequest "$base/$file" -OutFile (Join-Path $tmp $file) -UseBasicParsing $got = (Get-FileHash (Join-Path $tmp $file) -Algorithm SHA256).Hash.ToLower() if ($got -ne $sha.ToLower()) { throw "fetch: checksum mismatch for $file (expected $sha, got $got). Nothing was installed." } Expand-Archive (Join-Path $tmp $file) -DestinationPath $tmp -Force New-Item -ItemType Directory -Force -Path $dest | Out-Null Copy-Item (Join-Path $tmp 'fetch.exe') (Join-Path $dest 'fetch.exe') -Force } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (($userPath -split ';') -notcontains $dest) { [Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ";$dest").TrimStart(';'), 'User') $env:Path += ";$dest" Write-Host "Added $dest to your PATH (open a new terminal for other windows to see it)." } Write-Host "Installed $(& (Join-Path $dest 'fetch.exe') --version) at $dest\fetch.exe" Write-Host '' Write-Host 'Next: fetch login, then fetch agent install and fetch agent pair. See https://fetch.nightroll.app/download/'