# TRG Windows 11 Setup bootstrap # Served as text/plain so this command can execute it: # irm https://setup.tekrantgaming.com | iex & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $Version = '2.0.1' $PackageUri = 'https://setup.tekrantgaming.com/downloads/Lewis-PC-Automated-Setup-v2.0.1.zip' $ExpectedPackageHash = '9635e805757926fd9730fbfa18b00c4855648e3e1ae60a7f6df96aece8f91c39' $WindowsPowerShell = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' $ReleaseRoot = Join-Path $env:LOCALAPPDATA "TRG-Setup\$Version" $TemporaryRoot = Join-Path ([IO.Path]::GetTempPath()) ('TRG-Setup-' + [Guid]::NewGuid().ToString('N')) $DownloadPath = Join-Path $TemporaryRoot 'Lewis-PC-Automated-Setup.zip' $ApplicationPath = Join-Path $ReleaseRoot 'Lewis-PC-Automated-Setup\TRG-Setup-App.ps1' if ([string]::IsNullOrWhiteSpace($env:SystemRoot) -or [string]::IsNullOrWhiteSpace($env:LOCALAPPDATA)) { throw 'This setup must be started from an interactive Windows user session.' } if (-not (Test-Path -LiteralPath $WindowsPowerShell -PathType Leaf)) { throw "Windows PowerShell 5.1 was not found: $WindowsPowerShell" } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 New-Item -ItemType Directory -Path $TemporaryRoot -Force | Out-Null New-Item -ItemType Directory -Path $ReleaseRoot -Force | Out-Null try { Write-Host "Downloading TRG Windows 11 Setup v$Version..." -ForegroundColor Cyan Invoke-WebRequest -Uri $PackageUri -OutFile $DownloadPath -UseBasicParsing $ActualPackageHash = (Get-FileHash -LiteralPath $DownloadPath -Algorithm SHA256).Hash.ToLowerInvariant() if ($ActualPackageHash -cne $ExpectedPackageHash) { throw "The downloaded package failed its SHA-256 check. Expected $ExpectedPackageHash but found $ActualPackageHash." } Write-Host "Verified package SHA-256: $ActualPackageHash" -ForegroundColor Green if (Test-Path -LiteralPath $ReleaseRoot) { Remove-Item -LiteralPath $ReleaseRoot -Recurse -Force } New-Item -ItemType Directory -Path $ReleaseRoot -Force | Out-Null Expand-Archive -LiteralPath $DownloadPath -DestinationPath $ReleaseRoot -Force if (-not (Test-Path -LiteralPath $ApplicationPath -PathType Leaf)) { throw "The verified package did not contain the setup application: $ApplicationPath" } Write-Host 'Opening the setup application. Accept the Windows administrator prompt.' -ForegroundColor Cyan Write-Host 'This terminal will remain attached until setup finishes; use the new administrator setup window.' -ForegroundColor Cyan $LaunchArguments = '-NoLogo -NoProfile -STA -ExecutionPolicy Bypass -File "{0}"' -f $ApplicationPath $setupProcess = Start-Process -FilePath $WindowsPowerShell -ArgumentList $LaunchArguments -WorkingDirectory (Split-Path $ApplicationPath -Parent) -PassThru $setupProcess.WaitForExit() if ([int]$setupProcess.ExitCode -ne 0) { throw "TRG Windows 11 Setup stopped with exit code $([int]$setupProcess.ExitCode). Review the setup console and C:\ProgramData\TRG-Win11-Setup\Logs\TRG-Setup.log." } Write-Host 'TRG Windows 11 Setup finished successfully.' -ForegroundColor Green } finally { if (Test-Path -LiteralPath $TemporaryRoot) { Remove-Item -LiteralPath $TemporaryRoot -Recurse -Force -ErrorAction SilentlyContinue } } }