Last active
January 9, 2026 21:55
-
-
Save baaamn/123cbb9d1f192991ba9e45e4125499be to your computer and use it in GitHub Desktop.
Scoop Installation Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################################################### | |
| # Scoop Installation Script | |
| # Author: Wesley | |
| # Purpose: Automate Scoop setup, bucket registration, and app installation | |
| ############################################################################### | |
| # ------------------------------- | |
| # 1. Configure Execution Policy | |
| # ------------------------------- | |
| # Allow running local scripts for the current user | |
| Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force | |
| # ------------------------------- | |
| # 2. Install PowerShell Modules | |
| # ------------------------------- | |
| # Ensure PackageManagement and PSResourceGet are available | |
| Install-Module PowerShellGet -Repository PSGallery -Force -Scope CurrentUser -AllowClobber | |
| Install-Module Microsoft.PowerShell.PSResourceGet -Repository PSGallery -Force -Scope CurrentUser -AllowClobber | |
| Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted' | |
| Set-PSResourceRepository -Name 'PSGallery' -Trusted | |
| Install-Module -Name PackageManagement -Repository 'PSGallery' -Force -Scope CurrentUser -AllowClobber | |
| # ------------------------------- | |
| # 3. Setup Scoop Environment Paths | |
| # ------------------------------- | |
| $env:SCOOP = "C:\Users\$env:USERNAME\Scoop" | |
| $env:SCOOP_GLOBAL = "C:\ProgramData\Scoop_Global" | |
| # Create directories if missing | |
| if (!(Test-Path -Path $env:SCOOP)) { New-Item -ItemType Directory $env:SCOOP } | |
| if (!(Test-Path -Path $env:SCOOP_GLOBAL)) { New-Item -ItemType Directory $env:SCOOP_GLOBAL } | |
| # Persist environment variables | |
| [Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'User') | |
| [Environment]::SetEnvironmentVariable('SCOOP_GLOBAL', $env:SCOOP_GLOBAL, 'Machine') | |
| # ------------------------------- | |
| # 4. Install Scoop | |
| # ------------------------------- | |
| # User-specific variables | |
| $userProfile = "$env:USERPROFILE" | |
| ## Scoop | |
| # Install Scoop if it's not already installed | |
| function Install-Scoop { | |
| if (!(Get-Command scoop -ErrorAction SilentlyContinue)) { | |
| if ([bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) { | |
| Start-Process powershell.exe "-Command iwr -useb get.scoop.sh | iex" -Verb RunAs | |
| } else { | |
| Write-Output "Installing Scoop..." | |
| iwr -useb get.scoop.sh | iex | |
| } | |
| } | |
| } | |
| # Exclude Scoop paths from Windows Defender | |
| Add-MpPreference -ExclusionPath $env:SCOOP | |
| Add-MpPreference -ExclusionPath $env:SCOOP_GLOBAL | |
| # Enable long file paths in Windows | |
| Write-Output "Enabling Long Paths..." | |
| $command = 'Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1; exit' | |
| Start-Process -FilePath "powershell.exe" -ArgumentList "-Command Start-Process powershell -ArgumentList '-NoProfile -NoExit -Command ""$command""' -Verb RunAs" -Wait -NoNewWindow | |
| # ------------------------------- | |
| # 5. Define Scoop Aliases | |
| # ------------------------------- | |
| # Install Scoop App | |
| scoop alias add i 'foreach ($_ in $args) {scoop install $_ -su}' 'Install apps' | |
| # Uninstall Scoop App | |
| scoop alias add rm 'scoop uninstall $args[0]' 'Uninstall a scoop app' | |
| # List Scoop Apps | |
| scoop alias add ls 'scoop list' 'List installed scoop apps' | |
| # Update | |
| scoop alias add ua 'scoop update *' 'Update all installed apps' | |
| scoop alias add u 'scoop update $args[0]' 'Update apps, or Scoop itself' | |
| # Cleanup | |
| scoop alias add ca 'scoop cleanup *' 'Delete all old installed versions; better exit running programs first' | |
| # Scoop Clear Cache | |
| scoop alias add cc 'scoop cache rm *' 'Empty download cache' | |
| # scoop status | |
| scoop alias add s 'scoop status' 'Show status and check for new app versions' | |
| # ------------------------------- | |
| # 6. Install sudo (if missing) | |
| # ------------------------------- | |
| if (-not (Get-Command sudo -ErrorAction SilentlyContinue)) { | |
| Write-Output "Installing sudo using Scoop..." | |
| scoop install sudo | |
| } else { | |
| Write-Output "sudo already installed." | |
| } | |
| # ------------------------------- | |
| # 7. Install Required Apps | |
| # ------------------------------- | |
| $ReqApps = @('7zip','git','pwsh','python','scoop-search','oh-my-posh') | |
| foreach ($app in $ReqApps) { | |
| scoop install $app -su | |
| } | |
| # ------------------------------- | |
| # 8. Add Buckets | |
| # ------------------------------- | |
| # Add all known buckets except "games" | |
| $known = scoop bucket known | |
| $known | Where-Object {$_ -inotin @("games")} | ForEach-Object { scoop bucket add $_ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment