Skip to content

Instantly share code, notes, and snippets.

@acepace
Forked from jessfraz/boxstarter.ps1
Last active November 17, 2023 19:22
Show Gist options
  • Save acepace/d71a71c9cec4bed1ec1da0a6bd7b9a12 to your computer and use it in GitHub Desktop.
Save acepace/d71a71c9cec4bed1ec1da0a6bd7b9a12 to your computer and use it in GitHub Desktop.
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>, Modified by acepace@gmail.com
# Last Updated: 14-05-2021 (DD-MM-YYYY)
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
# or try
# Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1')); Get-Boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
# start http://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST>
# OR
# Install-BoxstarterPackage -PackageName https://gist.githubusercontent.com/acepace/d71a71c9cec4bed1ec1da0a6bd7b9a12/raw/boxstarter.ps1 -DisableReboots
#
# Learn more: http://boxstarter.org/Learn/WebLauncher
Set-ExecutionPolicy Unrestricted;
#. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#---- TEMPORARY ---
Disable-UAC
#install winget
#Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.
choco feature enable -n allowGlobalConfirmation
#--- Windows Settings ---
Disable-BingSearch
Disable-GameBarTips
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -DisableOpenFileExplorerToQuickAccess -DisableShowRecentFilesInQuickAccess -DisableShowFrequentFoldersInQuickAccess -EnableItemCheckBox
Set-BoxstarterTaskbarOptions -Size Small -Dock Bottom -Combine Full -Lock
# lets try this
DISM /Online /NoRestart /Disable-Feature /FeatureName:Printing-Foundation-InternetPrinting-Client
DISM /Online /NoRestart /Disable-Feature /FeatureName:Printing-XPSServices-Features
DISM /Online /NoRestart /Disable-Feature /FeatureName:WorkFolders-Client
DISM /Online /NoRestart /Disable-Feature /FeatureName:DirectPlay
DISM /Online /NoRestart /Disable-Feature /FeatureName:MicrosoftWindowsPowerShellV2
DISM /Online /NoRestart /Disable-Feature /FeatureName:MicrosoftWindowsPowerShellV2Root
DISM /Online /NoRestart /Disable-Feature /FeatureName:Printing-Foundation-Features
DISM /Online /NoRestart /Disable-Feature /FeatureName:WCF-Services45
DISM /Online /NoRestart /Disable-Feature /FeatureName:NetFx4-AdvSrvs
DISM /Online /NoRestart /Disable-Feature /FeatureName:WCF-TCP-PortSharing45
DISM /Online /NoRestart /Enable-Feature /FeatureName:Microsoft-Hyper-V-All
DISM /Online /NoRestart /Enable-Feature /FeatureName:HypervisorPlatform
DISM /Online /NoRestart /Enable-Feature /FeatureName:VirtualMachinePlatform
DISM /Online /NoRestart /Enable-Feature /FeatureName:Containers
DISM /Online /NoRestart /Enable-Feature /FeatureName:Client-ProjFS
DISM /Online /NoRestart /Enable-Feature /FeatureName:Windows-Defender-ApplicationGuard
DISM /Online /NoRestart /Enable-Feature /FeatureName:Containers-DisposableClientVM
DISM /Online /NoRestart /Remove-Capability /CapabilityName:Microsoft.Windows.PowerShell.ISE~~~~0.0.1.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:Media.WindowsMediaPlayer~~~~0.0.12.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:Microsoft.Windows.WordPad~~~~0.0.1.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:XPS.Viewer~~~~0.0.1.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:Print.Fax.Scan~~~~0.0.1.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:App.StepsRecorder~~~~0.0.1.0
DISM /Online /NoRestart /Remove-Capability /CapabilityName:Browser.InternetExplorer~~~~0.0.11.0
DISM /Online /NoRestart /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
winget install --accept-package-agreements --accept-source-agreements Microsoft.WindowsTerminal
# WSL installs
winget install --accept-package-agreements --accept-source-agreements 9P9TQF7MRM4R
# WSL install ubuntu latest
winget install --accept-package-agreements --accept-source-agreements 9PDXGNCFSCZV
winget install --accept-package-agreements --accept-source-agreements Microsoft.VCRedist.2010.x64
winget install --accept-package-agreements --accept-source-agreements Microsoft.VCRedist.2015+.x64
winget install --accept-package-agreements --accept-source-agreements -e --id Microsoft.VCRedist.2012.x64
winget install --accept-package-agreements --accept-source-agreements -e --id Microsoft.VCRedist.2013.x64
#--- Uninstall unecessary applications that come with Windows out of the box ---
@(
"king.com.CandyCrushSaga",
"Microsoft.BingWeather",
"Microsoft.BingNews",
"Microsoft.BingSports",
"Microsoft.BingFinance",
"Microsoft.3DBuilder",
"Microsoft.XboxApp",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.People",
"Microsoft.ZuneMusic",
"Microsoft.ZuneVideo",
"Microsoft.WindowsSoundRecorder",
"*Autodesk*",
"*BubbleWitch*",
"*CandyCrush*",
"*Dropbox*",
"*Facebook*",
"*Keeper*",
"*MarchofEmpires*",
"*Minecraft*",
"*Netflix*",
"*Plex*",
"*Spotify*",
"*Twitter*",
"*TikTok*",
"Microsoft.3DBuilder",
"Microsoft.SkypeApp"
) | ForEach-Object {
$pkg = Get-AppxPackage $_
if ($pkg) {
Write-Host "Removing Package: $($_)"
$pkg | Remove-AppxPackage
}
}
#--- Windows Settings ---
# Some from: @NickCraver's gist https://gist.github.com/NickCraver/7ebf9efbfd0c3eab72e9
# Privacy: Let apps use my advertising ID: Disable
If (-Not (Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo")) {
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo | Out-Null
}
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# WiFi Sense: HotSpot Sharing: Disable
If (-Not (Test-Path "HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) {
New-Item -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting | Out-Null
}
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting -Name value -Type DWord -Value 0
# WiFi Sense: Shared HotSpot Auto-Connect: Disable
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots -Name value -Type DWord -Value 0
# Start Menu: Disable Bing Search Results
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 0
# To Restore (Enabled):
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 1
# Disable Telemetry (requires a reboot to take effect)
# Note this may break Insider builds for your organization
# Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWord -Value 0
# Get-Service DiagTrack,Dmwappushservice | Stop-Service | Set-Service -StartupType Disabled
# Change Explorer home screen back to "This PC"
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 1
# Change it back to "Quick Access" (Windows 10 default)
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 2
# Better File Explorer
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Value 1
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneShowAllFolders -Value 1
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name MMTaskbarMode -Value 2
# These make "Quick Access" behave much closer to the old "Favorites"
# Disable Quick Access: Recent Files
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -Type DWord -Value 0
# Disable Quick Access: Frequent Folders
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowFrequent -Type DWord -Value 0
# To Restore:
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -Type DWord -Value 1
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowFrequent -Type DWord -Value 1
# Disable the Lock Screen (the one before password prompt - to prevent dropping the first character)
If (-Not (Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization)) {
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows -Name Personalization | Out-Null
}
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization -Name NoLockScreen -Type DWord -Value 1
# To Restore:
# Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization -Name NoLockScreen -Type DWord -Value 1
# Lock screen (not sleep) on lid close
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name AwayModeEnabled -Type DWord -Value 1
# To Restore:
# Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name AwayModeEnabled -Type DWord -Value 0
# Turn off People in Taskbar
If (-Not (Test-Path "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) {
New-Item -Path HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People | Out-Null
}
Set-ItemProperty -Path "HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name PeopleBand -Type DWord -Value 0
#--- Restore Temporary Settings ---
Enable-UAC
Enable-MicrosoftUpdate
Install-WindowsUpdate -acceptEula
Enable-RemoteDesktop
#--- Tools ---
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.ProcessExplorer
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.ZoomIt
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.Strings
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.Autoruns
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.ProcessMonitor
winget install --accept-package-agreements --accept-source-agreements Microsoft.Sysinternals.Sysmon
winget install --accept-package-agreements --accept-source-agreements Docker.DockerDesktop
winget install --accept-package-agreements --accept-source-agreements M2Team.NanaZip
winget install --accept-package-agreements --accept-source-agreements Notepad++.Notepad++
winget install --accept-package-agreements --accept-source-agreements VideoLAN.VLC
winget install --accept-package-agreements --accept-source-agreements Microsoft.PowerShell
winget install --accept-package-agreements --accept-source-agreements dotPDNLLC.paintdotnet
winget install --accept-package-agreements --accept-source-agreements WiresharkFoundation.Wireshark
winget install --accept-package-agreements --accept-source-agreements OpenJS.NodeJS
winget install --accept-package-agreements --accept-source-agreements Microsoft.PowerToys
# we comment out vscode to not have install as admin
#winget install --accept-package-agreements --accept-source-agreements Microsoft.VisualStudioCode --override "/NoContextMenuFiles /NoContextMenuFolders"
winget install -e --id VivaldiTechnologies.Vivaldi
#setting up git install, which is a pain to pass in different settings.
$gitinit_content = '[Setup]YYLang=defaultYYDir=C:\Program Files\GitYYGroup=GitYYNoIcons=0YYSetupType=defaultYYComponents=gitlfs,assoc,autoupdate,scalarYYTasks=YYEditorOption=NotepadYYCustomEditorPath=YYDefaultBranchOption=YYPathOption=CmdYYSSHOption=ExternalOpenSSHYYTortoiseOption=falseYYCURLOption=WinSSLYYCRLFOption=CRLFAlwaysYYBashTerminalOption=MinTTYYYGitPullBehaviorOption=MergeYYUseCredentialManager=EnabledYYPerformanceTweaksFSCache=EnabledYYEnableSymlinks=EnabledYYEnablePseudoConsoleSupport=DisabledYYEnableFSMonitor=Enabled'
$gitcontent = $gitinit_content -replace "YY","`r`n"
Set-Content -Path 'gitinstall.ini' -Value $gitcontent
winget install --accept-package-agreements --accept-source-agreements Git.Git --override "/SILENT /LOADINF=gitinstall.ini"
remove-item 'gitinstall.ini'
# oh my posh
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
winget install JanDeDobbeleer.OhMyPosh
Install-Module -Name Terminal-Icons -Repository PSGallery
#prep for oh-my-post prompt
new-item -type file -path $profile -force
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\stelbent-compact.minimal.omp.json" | Invoke-Expression
Install-Module posh-git -Scope CurrentUser
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
#### choco leftovers
#--- Fonts ---
choco install inconsolata -y
choco install cascadiacode cascadiamono cascadiacodepl cascadiamonopl
choco install cascadia-code-nerd-font
choco install poshgit -y --ignore-dependencies
#--- Rename the Computer ---
# Requires restart, or add the -Restart flag
#$computername = "AcePrimaryZ"
#if ($env:computername -ne $computername) {
# Rename-Computer -NewName $computername
#}
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment