Skip to content

Instantly share code, notes, and snippets.

@dotneB
Forked from mikepruett3/shell-setup.ps1
Last active April 25, 2024 10:01
Show Gist options
  • Save dotneB/29059e38f7d582bbc4b0ba02511f20e5 to your computer and use it in GitHub Desktop.
Save dotneB/29059e38f7d582bbc4b0ba02511f20e5 to your computer and use it in GitHub Desktop.
Packages to install via scoop, winget, choco, and other tools...
<#
.SYNOPSIS
Script to Initialize my custom powershell setup.
.DESCRIPTION
Script uses scoop
.NOTES
**NOTE** Will configure the Execution Policy for the "CurrentUser" to Unrestricted.
Author: Mike Pruett
Date: October 18th, 2018
Last Updated on August 4th, 2023
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/dotneB/29059e38f7d582bbc4b0ba02511f20e5/raw/db4bf2f1ed06136b127413fd6812b8adce94edbf/shell-setup.ps1'))"
#>
$VerbosePreference = "Continue"
function Install-ScoopApp {
param (
[string]$Package
)
Write-Verbose -Message "Preparing to install $Package"
if (! (scoop info $Package).Installed ) {
Write-Verbose -Message "Installing $Package"
scoop install $Package
} else {
Write-Verbose -Message "Package $Package already installed! Skipping..."
}
}
function Install-WinGetApp {
param (
[string]$PackageID
)
Write-Verbose -Message "Preparing to install $PackageID"
# Added accept options based on this issue - https://github.com/microsoft/winget-cli/issues/1559
#$listApp = winget list --exact -q $PackageID --accept-source-agreements
#if (winget list --exact --id "$PackageID" --accept-source-agreements) {
# Write-Verbose -Message "Package $PackageID already installed! Skipping..."
#} else {
# Write-Verbose -Message "Installing $Package"
# winget install --silent --id "$PackageID" --accept-source-agreements --accept-package-agreements
#}
Write-Verbose -Message "Installing $Package"
winget install --silent --id "$PackageID" --accept-source-agreements --accept-package-agreements
}
function Remove-InstalledApp {
param (
[string]$Package
)
Write-Verbose -Message "Uninstalling: $Package"
Start-Process -FilePath "PowerShell" -ArgumentList "Get-AppxPackage","-AllUsers","-Name","'$Package'" -Verb RunAs -WindowStyle Hidden
}
function Enable-Bucket {
param (
[string]$Bucket
)
if (!($(scoop bucket list).Name -eq "$Bucket")) {
Write-Verbose -Message "Adding Bucket $Bucket to scoop..."
scoop bucket add $Bucket
} else {
Write-Verbose -Message "Bucket $Bucket already added! Skipping..."
}
}
# Configure ExecutionPolicy to Unrestricted for CurrentUser Scope
if ((Get-ExecutionPolicy -Scope CurrentUser) -notcontains "Unrestricted") {
Write-Verbose -Message "Setting Execution Policy for Current User..."
Start-Process -FilePath "PowerShell" -ArgumentList "Set-ExecutionPolicy","-Scope","CurrentUser","-ExecutionPolicy","Unrestricted","-Force" -Verb RunAs -Wait
Write-Output "Restart/Re-Run script!!!"
Start-Sleep -Seconds 10
Break
}
# Install Scoop, if not already installed
#$scoopInstalled = Get-Command "scoop"
if ( !(Get-Command -Name "scoop" -CommandType Application -ErrorAction SilentlyContinue | Out-Null) ) {
Write-Verbose -Message "Installing Scoop..."
iex ((New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh'))
}
# Install OpenSSH.Client on Windows 10+
@'
if ((Get-WindowsCapability -Online -Name OpenSSH.Client*).State -ne "Installed") {
Add-WindowsCapability -Online -Name OpenSSH.Client*
}
'@ > "${Env:Temp}\openssh.ps1"
Start-Process -FilePath "PowerShell" -ArgumentList "${Env:Temp}\openssh.ps1" -Verb RunAs -Wait -WindowStyle Hidden
Remove-Item -Path "${Env:Temp}\openssh.ps1" -Force
# Configure git
Install-WinGetApp -PackageID "Git.Git"
Start-Sleep -Seconds 5
refreshenv
Start-Sleep -Seconds 5
if (!$(git config --global credential.helper) -eq "manager-core") {
git config --global credential.helper manager-core
}
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
# Configure Aria2 Download Manager
Install-ScoopApp -Package "aria2"
if (!$(scoop config aria2-enabled) -eq $True) {
scoop config aria2-enabled true
}
if (!$(scoop config aria2-warning-enabled) -eq $False) {
scoop config aria2-warning-enabled false
}
if (!(Get-ScheduledTaskInfo -TaskName "Aria2RPC" -ErrorAction Ignore)) {
@'
$Action = New-ScheduledTaskAction -Execute $Env:UserProfile\scoop\apps\aria2\current\aria2c.exe -Argument "--enable-rpc --rpc-listen-all" -WorkingDirectory $Env:UserProfile\Downloads
$Trigger = New-ScheduledTaskTrigger -AtStartup
$Principal = New-ScheduledTaskPrincipal -UserID "$Env:ComputerName\$Env:Username" -LogonType S4U
$Settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit 0 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "Aria2RPC" -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings
'@ > $Env:Temp\aria2.ps1
Start-Process -FilePath "PowerShell" -ArgumentList "$Env:Temp\aria2.ps1" -Verb RunAs -Wait #-WindowStyle Hidden
Remove-Item -Path $Env:Temp\aria2.ps1 -Force
}
## Add Buckets
Enable-Bucket -Bucket "extras"
Enable-Bucket -Bucket "nerd-fonts"
# UNIX Tools
Write-Verbose -Message "Removing curl Alias..."
if (Get-Alias -Name curl -ErrorAction SilentlyContinue) {
Remove-Item alias:curl
}
if (!($Env:TERM)) {
Write-Verbose -Message "Setting TERM User Environment Variable"
[System.Environment]::SetEnvironmentVariable("TERM", "xterm-256color", "USER")
}
# Install Scoop Packages
$Scoop = @(
"cacert",
"open-log-viewer",
"lame",
"busybox",
"sudo",
"python"
)
foreach ($item in $Scoop) {
Install-ScoopApp -Package "$item"
}
# Install WinGet Packages
$WinGet = @(
"Microsoft.DotNet.DesktopRuntime.3_1",
"Microsoft.DotNet.DesktopRuntime.5",
"Microsoft.DotNet.DesktopRuntime.6",
"Microsoft.DotNet.DesktopRuntime.7",
"Microsoft.WindowsTerminal",
"7zip.7zip",
"Microsoft.Sysinternals.ProcessExplorer",
"Gyan.FFmpeg",
"voidtools.Everything.Lite",
"AntibodySoftware.WizTree",
"Microsoft.OpenJDK.17",
"Rustlang.Rust.MSVC",
"dotPDNLLC.paintdotnet",
"UderzoSoftware.SpaceSniffer",
#"Google.Chrome",
"ScooterSoftware.BeyondCompare4",
#"Piriform.Speccy",
"Piriform.Defraggler",
"Starship.Starship",
"Discord.Discord",
"HandBrake.HandBrake",
"HandBrake.HandBrake.CLI",
"clsid2.mpc-hc",
"Plex.Plex",
"VideoLAN.VLC",
"OBSProject.OBSStudio",
"EpicGames.EpicGamesLauncher",
"Ubisoft.Connect",
"ElectronicArts.EADesktop",
"SomePythonThings.WingetUIStore",
"Appest.TickTick",
"Notion.Notion",
"Spotify.Spotify",
"Dropbox.Dropbox",
"MedalB.V.Medal",
"Elgato.StreamDeck",
"Elgato.ControlCenter",
"Elgato.4KCaptureUtility",
#"Nvidia.GeForceExperience",
"Citrix.Workspace",
"Parsec.Parsec",
"AgileBits.1Password",
"AgileBits.1Password.CLI",
"Snaz.Snaz",
#"Microsoft.Teams",
"Malwarebytes.Malwarebytes",
"Greenshot.Greenshot",
"Audacity.Audacity",
"Fork.Fork",
"IrfanSkiljan.IrfanView",
"SpeedCrunch.SpeedCrunch",
"Meltytech.Shotcut",
#"SteelSeries.GG",
"CodeSector.TeraCopy",
"IDRIX.VeraCrypt",
"Volta.Volta",
#"Google.PlayGames.Beta",
"Google.Drive",
#"Microsoft.OneDrive",
"Mozilla.Firefox",
"Bitwarden.Bitwarden"
)
foreach ($item in $WinGet) {
Install-WinGetApp -PackageID "$item"
}
# Custom WinGet install for VSCode
#winget install Microsoft.VisualStudioCode --override '/SILENT /mergetasks="!runcode,addcontextmenufiles,addcontextmenufolders"'
# Remove unused Packages/Applications
Write-Verbose -Message "Removing Unused Applications..."
$RemoveApps = @(
"*3DPrint*",
"Microsoft.MixedReality.Portal")
foreach ($item in $RemoveApps) {
Remove-InstalledApp -Package $item
}
# Install Windows SubSystems for Linux
$wslInstalled = Get-Command "wsl" -CommandType Application -ErrorAction Ignore
if (!$wslInstalled) {
Write-Verbose -Message "Installing Windows SubSystems for Linux..."
Start-Process -FilePath "PowerShell" -ArgumentList "wsl","--install" -Verb RunAs -Wait -WindowStyle Hidden
}
Install-WinGetApp -PackageID Canonical.Ubuntu.2204
Write-Output "Install complete! Please reboot your machine/worksation!"
Start-Sleep -Seconds 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment