# Check if the script is running in an elevated (administrator) session $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) $isElevated = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) $runAsAdmin = $false if ($isElevated) { Write-Host "WARNING: This script is running with administrator privileges." -ForegroundColor Yellow Write-Host "Scoop is designed for per-user installs and installing as admin is NOT recommended." -ForegroundColor Yellow Write-Host "It is strongly advised to exit and re-run this script in a normal (non-elevated) PowerShell window." -ForegroundColor Yellow Write-Host "" $elevatedResponse = Read-Host "Install Scoop as administrator anyway? (y/n)" if ($elevatedResponse -match "^[yY]") { $runAsAdmin = $true } else { Write-Host "Exiting. Please re-run this script from a non-elevated PowerShell session." -ForegroundColor Magenta exit } } # Ensure execution policy allows script execution for the current user Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force # Install Scoop Write-Host "Installing Scoop package manager..." -ForegroundColor Cyan if ($runAsAdmin) { # Scoop blocks admin installs by default; -RunAsAdmin is required to override Invoke-Expression "& {$(Invoke-RestMethod -Uri https://get.scoop.sh)} -RunAsAdmin" } else { Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression } # Refresh the PATH environment variable for the current session # This is necessary so the 'scoop' command is recognized immediately after installation $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") # Install Git Write-Host "Installing Git..." -ForegroundColor Cyan scoop install git # Add the extras bucket Write-Host "Adding the 'extras' bucket..." -ForegroundColor Cyan scoop bucket add extras Write-Host "Core setup complete! Scoop, Git, and the extras bucket are installed." -ForegroundColor Green # Prompt for optional packages Write-Host "" $response = Read-Host "Would you like to optionally install 7zip and aria2 (recommended for faster downloads)? (y/n)" if ($response -match "^[yY]") { Write-Host "Installing 7zip and aria2..." -ForegroundColor Cyan scoop install 7zip aria2 Write-Host "7zip and aria2 have been installed successfully!" -ForegroundColor Green } else { Write-Host "Skipping optional package installation." -ForegroundColor Yellow } Write-Host "Setup finished. You may need to restart your terminal for all PATH changes to take effect." -ForegroundColor Magenta