|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | + RackStack Bootstrap Installer — download and run with one command. |
| 4 | +
|
| 5 | +.DESCRIPTION |
| 6 | + Downloads the latest RackStack.exe from GitHub Releases and optionally |
| 7 | + runs it with CLI parameters. Designed for remote deployment via |
| 8 | + Ansible, RMM tools, PDQ, or any tool that can execute PowerShell. |
| 9 | +
|
| 10 | + One-liner usage (run as Administrator): |
| 11 | + irm https://raw.githubusercontent.com/TheAbider/RackStack/master/Install-RackStack.ps1 | iex |
| 12 | +
|
| 13 | + With parameters (download + run): |
| 14 | + & ([scriptblock]::Create((irm https://raw.githubusercontent.com/TheAbider/RackStack/master/Install-RackStack.ps1))) |
| 15 | +
|
| 16 | + Ansible example: |
| 17 | + ansible windows -m win_shell -a "irm https://raw.githubusercontent.com/TheAbider/RackStack/master/Install-RackStack.ps1 | iex" |
| 18 | +
|
| 19 | +.PARAMETER Action |
| 20 | + CLI action to run after download: Cleanup, Debloat, HealthCheck, QuickScan, Batch |
| 21 | +
|
| 22 | +.PARAMETER Tier |
| 23 | + Profile tier: Light, Standard, Aggressive (default: Standard) |
| 24 | +
|
| 25 | +.PARAMETER Silent |
| 26 | + Auto-confirm all prompts |
| 27 | +
|
| 28 | +.PARAMETER InstallPath |
| 29 | + Where to save RackStack.exe (default: C:\Temp\RackStack) |
| 30 | +
|
| 31 | +.PARAMETER NoRun |
| 32 | + Download only, do not execute |
| 33 | +
|
| 34 | +.NOTES |
| 35 | + Requires: PowerShell 5.1+, Administrator privileges, Internet access |
| 36 | +#> |
| 37 | + |
| 38 | +param( |
| 39 | + [ValidateSet('Cleanup', 'Debloat', 'HealthCheck', 'Batch', 'QuickScan')] |
| 40 | + [string]$Action = 'QuickScan', |
| 41 | + |
| 42 | + [ValidateSet('Light', 'Standard', 'Aggressive')] |
| 43 | + [string]$Tier = 'Standard', |
| 44 | + |
| 45 | + [switch]$Silent, |
| 46 | + |
| 47 | + [string]$InstallPath = 'C:\Temp\RackStack', |
| 48 | + |
| 49 | + [switch]$NoRun |
| 50 | +) |
| 51 | + |
| 52 | +$ErrorActionPreference = 'Stop' |
| 53 | + |
| 54 | +# Enforce TLS 1.2 |
| 55 | +[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 |
| 56 | + |
| 57 | +Write-Host "" |
| 58 | +Write-Host " RackStack Bootstrap Installer" -ForegroundColor Cyan |
| 59 | +Write-Host " =============================" -ForegroundColor Cyan |
| 60 | +Write-Host "" |
| 61 | + |
| 62 | +# Check for admin |
| 63 | +$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) |
| 64 | +if (-not $isAdmin) { |
| 65 | + Write-Host " ERROR: This script requires Administrator privileges." -ForegroundColor Red |
| 66 | + Write-Host " Run PowerShell as Administrator and try again." -ForegroundColor Yellow |
| 67 | + exit 1 |
| 68 | +} |
| 69 | + |
| 70 | +# Create install directory |
| 71 | +if (-not (Test-Path -LiteralPath $InstallPath)) { |
| 72 | + Write-Host " Creating directory: $InstallPath" -ForegroundColor Gray |
| 73 | + New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null |
| 74 | +} |
| 75 | + |
| 76 | +$exePath = Join-Path $InstallPath "RackStack.exe" |
| 77 | + |
| 78 | +# Get latest release URL from GitHub API |
| 79 | +Write-Host " Checking latest release..." -ForegroundColor Gray |
| 80 | +try { |
| 81 | + $releaseInfo = Invoke-RestMethod -Uri "https://api.github.com/repos/TheAbider/RackStack/releases/latest" -UseBasicParsing |
| 82 | + $version = $releaseInfo.tag_name |
| 83 | + $exeAsset = $releaseInfo.assets | Where-Object { $_.name -eq "RackStack.exe" } | Select-Object -First 1 |
| 84 | + |
| 85 | + if (-not $exeAsset) { |
| 86 | + Write-Host " ERROR: RackStack.exe not found in latest release." -ForegroundColor Red |
| 87 | + exit 1 |
| 88 | + } |
| 89 | + |
| 90 | + $downloadUrl = $exeAsset.browser_download_url |
| 91 | + Write-Host " Latest version: $version" -ForegroundColor Green |
| 92 | +} |
| 93 | +catch { |
| 94 | + Write-Host " ERROR: Failed to query GitHub releases: $_" -ForegroundColor Red |
| 95 | + exit 1 |
| 96 | +} |
| 97 | + |
| 98 | +# Check if we already have this version |
| 99 | +$needsDownload = $true |
| 100 | +if (Test-Path -LiteralPath $exePath) { |
| 101 | + try { |
| 102 | + $existingVersion = (Get-Item $exePath).VersionInfo.FileVersion |
| 103 | + if ($existingVersion -and $version -eq "v$existingVersion") { |
| 104 | + Write-Host " Already up to date ($version)" -ForegroundColor Green |
| 105 | + $needsDownload = $false |
| 106 | + } |
| 107 | + else { |
| 108 | + Write-Host " Updating from v$existingVersion to $version" -ForegroundColor Yellow |
| 109 | + } |
| 110 | + } |
| 111 | + catch { |
| 112 | + # Can't read version, re-download |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +# Download |
| 117 | +if ($needsDownload) { |
| 118 | + Write-Host " Downloading RackStack.exe ($([math]::Round($exeAsset.size / 1MB, 1)) MB)..." -ForegroundColor Gray |
| 119 | + try { |
| 120 | + Invoke-WebRequest -Uri $downloadUrl -OutFile $exePath -UseBasicParsing |
| 121 | + Write-Host " Downloaded to: $exePath" -ForegroundColor Green |
| 122 | + } |
| 123 | + catch { |
| 124 | + Write-Host " ERROR: Download failed: $_" -ForegroundColor Red |
| 125 | + exit 1 |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +if ($NoRun) { |
| 130 | + Write-Host "" |
| 131 | + Write-Host " Download complete. Run manually:" -ForegroundColor Cyan |
| 132 | + Write-Host " $exePath -Action $Action -Tier $Tier -Silent" -ForegroundColor White |
| 133 | + Write-Host "" |
| 134 | + exit 0 |
| 135 | +} |
| 136 | + |
| 137 | +# Run with CLI parameters |
| 138 | +Write-Host "" |
| 139 | +Write-Host " Launching RackStack -Action $Action -Tier $Tier$(if ($Silent) { ' -Silent' })..." -ForegroundColor Cyan |
| 140 | +Write-Host "" |
| 141 | + |
| 142 | +$args = @("-Action", $Action, "-Tier", $Tier) |
| 143 | +if ($Silent) { $args += "-Silent" } |
| 144 | + |
| 145 | +try { |
| 146 | + $process = Start-Process -FilePath $exePath -ArgumentList $args -Wait -PassThru -NoNewWindow |
| 147 | + exit $process.ExitCode |
| 148 | +} |
| 149 | +catch { |
| 150 | + Write-Host " ERROR: Failed to launch RackStack: $_" -ForegroundColor Red |
| 151 | + exit 1 |
| 152 | +} |
0 commit comments