Last active
July 6, 2021 10:01
-
-
Save arkadiyasuratov/2fed1efe28c7b2b4b1d6561481d7c2c3 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env pwsh | |
<# | |
.SYNOPSIS | |
BoxStarter script to configure Windows 10 PC. | |
.DESCRIPTION | |
Boxstarter repeats the _entire_ script after restart. | |
When completed you shoud Restart-Computer to ensure UAC is enabled. | |
Allow local PowerShell scripts to run: | |
Set-ExecutionPolicy RemoteSigned | |
Install BoxStarter: | |
. { Invoke-WebRequest -useb http://boxstarter.org/bootstrapper.ps1 } | Invoke-Expression; get-boxstarter -Force | |
Run by calling the following from an **elevated** command-prompt. | |
Remove -DisableReboots parameter to allow the script to reboot as required. | |
Install-BoxstarterPackage -PackageName <URL-TO-RAW-GIST> -DisableReboots | |
.NOTES | |
Author: Arkadiy Asuratov | |
Created: 2021-07-06 | |
Credits: | |
https://gist.github.com/ian-noble/6ab9014300792aebca338abed12aaa58 | |
https://gist.github.com/zloeber/9c2d659a2a8f063af26c9ba0285c7e78 | |
https://gist.github.com/reneweiser/222aec65251f928a3694704af1471a75 | |
https://gist.github.com/KZeronimo/3dd360bece3341a322335469a0a813ea | |
https://gist.github.com/flcdrg/87802af4c92527eb8a30 | |
https://david.gardiner.net.au/2018/07/boxstarter-and-chocolatey-tips.html | |
https://pastebin.com/vTw2HQA4 | |
https://github.com/microsoft/windows-dev-box-setup-scripts | |
.EXAMPLE | |
Win+R to Run WebLauncher | |
iexplore http://boxstarter.org/package/url?<URL-TO-RAW-GIST> | |
OR | |
msedge http://boxstarter.org/package/url?<URL-TO-RAW-GIST> | |
.EXAMPLE | |
PowerShell to Run WebLauncher | |
START https://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST> | |
Start-Process -file iexplore -arg 'https://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST>' -PassThru | |
Start-Process -file msedge -arg 'https://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST>' -PassThru | |
#> | |
Write-Verbose 'Checking Windows Version' | |
If ([Environment]::OSVersion.Version.Major -ne 10) { | |
Write-Error 'Upgrade to Windows 10 before running this script' | |
Exit | |
} | |
Write-Verbose 'Checking Windows Revision' | |
If ((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId -lt 2004) { | |
Write-Error 'You need to run Windows Update and install Feature Updates to at least version 2004' | |
Exit | |
} | |
Write-Verbose 'Temporarily disable UAC' | |
Disable-UAC | |
Function Initialize-BoxstarterInstaller { | |
# Sets options on the Windows Explorer shell | |
Set-WindowsExplorerOptions ` | |
-EnableShowHiddenFilesFoldersDrives ` | |
-EnableShowFileExtensions ` | |
-DisableOpenFileExplorerToQuickAccess ` | |
-DisableShowRecentFilesInQuickAccess ` | |
-DisableShowFrequentFoldersInQuickAccess ` | |
-DisableShowRibbon ` | |
# Sets options for the Windows Task Bar | |
Set-BoxstarterTaskbarOptions -Size Small -Dock Bottom -Combine Always -AlwaysShowIconsOff | |
# Turns off the tips displayed by the XBox GameBar | |
Disable-GameBarTips | |
# Remote Desktop access | |
Enable-RemoteDesktop | |
# Sets the execution policy for the current account | |
Update-ExecutionPolicy RemoteSigned | |
} | |
Function Install-WinGetPackages { | |
$repoName = 'microsoft/winget-cli' | |
$assetPattern = '*.msixbundle' | |
$extractDirectory = "$env:USERPROFILE\Downloads" | |
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest" | |
$asset = (Invoke-WebRequest $releasesUri -UseBasicParsing | ConvertFrom-Json).assets | Where-Object name -Like $assetPattern | |
$downloadUri = $asset.browser_download_url | |
$extractPath = [System.IO.Path]::Combine($extractDirectory, $asset.name) | |
If (-Not (Test-Path $extractPath)) { | |
Invoke-WebRequest -Uri $downloadUri -Out $extractPath -UseBasicParsing | |
} | |
Add-AppxPackage -Path $extractPath | |
winget install --exact Microsoft.WindowsTerminal | |
winget install --exact Microsoft.MouseandKeyboardCenter | |
winget install --exact Figma.Figma | |
winget install --exact Quicklook | |
} | |
Function Install-ChocolateyPackages { | |
# https://github.com/mwrock/boxstarter/issues/241#issuecomment-336028348 | |
$chocoCache = (Join-Path ([Environment]::GetEnvironmentVariable('LocalAppData')) 'Temp\ChocoCache') | |
New-Item -Path $chocoCache -ItemType directory -Force | Out-Null | |
$common = "--cacheLocation=`"$chocoCache`"" | |
# Install / Upgrade Chocolatey | |
choco upgrade -y chocolatey | |
choco feature enable -n=allowGlobalConfirmation --no-progress --limitoutput | |
choco feature enable -n=useRememberedArgumentsForUpgrades --no-progress --limitoutput | |
# Install / Upgrade Boxstarter | |
choco upgrade -y boxstarter | |
# Browsers | |
cinst firefox $common | |
choco pin add -n="firefox" | |
cinst googlechrome $common | |
choco pin add -n="googlechrome" | |
# Messaging Apps | |
cinst telegram.install $common | |
choco pin add -n="telegram.install" | |
cinst microsoft-teams $common | |
choco pin add -n="microsoft-teams" | |
# Fonts | |
cinst firacode $common | |
cinst cascadiacodepl $common | |
cinst sourcecodepro $common | |
cinst dejavufonts $common | |
cinst opensans $common | |
# Remote Control | |
cinst unifiedremote $common | |
# Security & VPN | |
cinst keepass $common | |
cinst keepass-plugin-keepassotp $common | |
cinst gpg4win $common | |
cinst zerotier-one $common | |
cinst bitwarden $common | |
choco pin add -n="bitwarden" | |
cinst pia $common | |
choco pin add -n="pia" | |
# Command-line tools | |
cinst powershell-core $common --install-arguments='"ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 ENABLE_PSREMOTING=1"' | |
cinst git.install $common --params '/GitOnlyOnPath /NoAutoCrlf /WindowsTerminal /NoShellIntegration /SChannel' | |
cinst exiftool $common | |
cinst adb $common | |
cinst ffmpeg $common | |
# Office Tools | |
cinst calibre $common | |
cinst toggl $common | |
choco pin add -n="toggl" | |
# Developer Tools | |
cinst docker-desktop $common | |
choco pin add -n="docker-desktop" | |
cinst vscode.install $common | |
choco pin add -n="vscode.install" | |
cinst notepadplusplus.install $common | |
cinst heidisql $common | |
cinst putty.install $common | |
cinst insomnia-rest-api-client $common | |
cinst winmerge $common | |
# Compression and Backup | |
cinst 7zip.install $common | |
cinst nextcloud-client $common | |
# System Utilities | |
cinst autoruns $common | |
cinst geekuninstaller $common | |
cinst cpu-z $common | |
cinst windirstat $common | |
} | |
Function Install-WindowsSubsystemLinux { | |
$downloadUri = 'https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi' | |
choco install Microsoft-Hyper-V-All -source windowsFeatures | |
choco install Microsoft-Windows-Subsystem-Linux -source windowsfeatures | |
If (Test-PendingReboot) { Invoke-Reboot } | |
Invoke-WebRequest -Uri $downloadUri -OutFile ~/Downloads/wsl_update_x64.msi -UseBasicParsing | |
Start-Process msiexec.exe -Wait -ArgumentList '/I ~/Downloads/wsl_update_x64.msi /quiet /norestart' | |
wsl --set-default-version 2 | |
# Will be available in future builds | |
# https://docs.microsoft.com/en-us/windows/wsl/install-win10#simplified-installation-for-windows-insiders | |
# wsl --install -d Ubuntu | |
} | |
Function Uninstall-DefaultWindowsPackages { | |
# source: https://github.com/microsoft/windows-dev-box-setup-scripts/blob/master/scripts/RemoveDefaultApps.ps1 | |
$applicationList = @( | |
'Microsoft.BingFinance' | |
'Microsoft.3DBuilder' | |
'Microsoft.Microsoft3DViewer' | |
'Microsoft.BingFinance' | |
'Microsoft.BingNews' | |
'Microsoft.BingSports' | |
'Microsoft.BingWeather' | |
'Microsoft.CommsPhone' | |
'Microsoft.Getstarted' | |
'Microsoft.WindowsMaps' | |
'*MarchofEmpires*' | |
'Microsoft.GetHelp' | |
'Microsoft.Messaging' | |
'*Minecraft*' | |
'Microsoft.MicrosoftOfficeHub' | |
'Microsoft.OneConnect' | |
'Microsoft.WindowsPhone' | |
'Microsoft.WindowsSoundRecorder' | |
'*Solitaire*' | |
'Microsoft.MicrosoftStickyNotes' | |
'Microsoft.MixedReality.Portal' | |
'Microsoft.Office.Sway' | |
'Microsoft.XboxApp' | |
'Microsoft.XboxIdentityProvider' | |
'Microsoft.ZuneMusic' | |
'Microsoft.ZuneVideo' | |
'Microsoft.NetworkSpeedTest' | |
'Microsoft.FreshPaint' | |
'Microsoft.Print3D' | |
'Microsoft.SkypeApp' | |
'Microsoft.Office.OneNote' | |
'*Autodesk*' | |
'*BubbleWitch*' | |
'king.com*' | |
'G5*' | |
'*Dell*' | |
'*Facebook*' | |
'*Keeper*' | |
'*Netflix*' | |
'*Spotify*' | |
'*Twitter*' | |
'*Plex*' | |
'*.Duolingo-LearnLanguagesforFree' | |
'*.EclipseManager' | |
'ActiproSoftwareLLC.562882FEEB491' # Code Writer | |
'*.AdobePhotoshopExpress' | |
); | |
foreach ($app in $applicationList) { | |
Write-Output "Trying to remove $app" | |
Get-AppxPackage $app -AllUsers | Remove-AppxPackage | |
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -Like $app | Remove-AppxProvisionedPackage -Online | |
} | |
} | |
#--- Initialize Boxstarter Installer --- | |
Write-Host 'Initialize Boxstarter Installer' -ForegroundColor 'Yellow' | |
Initialize-BoxstarterInstaller | |
#--- Uninstall unnecessary applications that come with Windows out of the box --- | |
Write-Host 'Uninstall some applications that come with Windows out of the box' -ForegroundColor 'Yellow' | |
Uninstall-DefaultWindowsPackages | |
#--- Install WinGet --- | |
Write-Host 'Install WinGet CLI' -ForegroundColor 'Yellow' | |
Install-WinGetPackages | |
#--- Install Chocolatey Packages --- | |
Write-Verbose 'Install Chocolatey Packages' | |
Install-ChocolateyPackages | |
#--- Install Windows Subsystem Linux 2 --- | |
Write-Verbose 'Install WSL 2' | |
Install-WindowsSubsystemLinux | |
#--- Restore UAC --- | |
Write-Verbose 'Restore UAC' | |
Enable-UAC | |
#--- Check for / install Windows Updates --- | |
Write-Verbose 'Check for / install Windows Updates' | |
Enable-MicrosoftUpdate | |
Install-WindowsUpdate -acceptEula | |
If (Test-PendingReboot) { Invoke-Reboot } | |
Write-Output 'Complete' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment