Skip to content

Instantly share code, notes, and snippets.

@aphex
Last active February 27, 2021 16:00
Show Gist options
  • Save aphex/0b39cfa86e14a73e53fe555903b4cab2 to your computer and use it in GitHub Desktop.
Save aphex/0b39cfa86e14a73e53fe555903b4cab2 to your computer and use it in GitHub Desktop.
# reference https://gist.github.com/zloeber/9c2d659a2a8f063af26c9ba0285c7e78
# Step 1: Open an elevated PowerShell prompt and set execution policy
# Set-ExecutionPolicy Unrestricted -Force
#
# Step 2: Install Boxstarter
# . { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; Get-Boxstarter -Force
#
# Step 3: Store your user credential (select your username name and provide your password in the dialog box)
# $cred=Get-Credential
#
# Step 4: Run the script
# Install-BoxstarterPackage -PackageName "gist-raw-url" -Credential $cred
#
# Step 5: Updater Windows Terminal
# Set defaultProfile GUID to ubuntu
# then set defaults to
# "defaults": {
# "colorScheme": "Dracula",
# "fontFace": "Cascadia Code PL"
# },
#
# Step 6: Run Ubuntu
# Configure User/Password
$Boxstarter.RebootOk=$true
$Boxstarter.NoPassword=$true
$Boxstarter.AutoLogin=$true
##################
# Configuration Functions
##################
# Disable Telemetry
Function DisableTelemetry {
Write-Host "Disabling Telemetry..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null
Get-Service DiagTrack,Dmwappushservice | Stop-Service | Set-Service -StartupType Disabled
}
# Disable Wi-Fi Sense
Function DisableWiFiSense {
Write-Host "Disabling Wi-Fi Sense..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "AutoConnectAllowedOEM" -Type Dword -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "WiFISenseAllowed" -Type Dword -Value 0
}
# Disable Web Search in Start Menu
Function DisableWebSearch {
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -Type DWord -Value 1
}
# Disable Application suggestions and automatic installation
Function DisableAppSuggestions {
Write-Host "Disabling Application suggestions..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1
}
# Disable Location Tracking
Function DisableLocationTracking {
Write-Host "Disabling Location Tracking..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value 0
}
# Disable Feedback
Function DisableFeedback {
Write-Host "Disabling Feedback..."
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Force | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null
}
# Disable Advertising ID
Function DisableAdvertisingID {
Write-Host "Disabling Advertising ID..."
If (!(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
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" -Name "TailoredExperiencesWithDiagnosticDataEnabled" -Type DWord -Value 0
}
# Disable Cortana
Function DisableCortana {
Write-Host "Disabling Cortana..."
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Force | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -Type DWord -Value 0
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Force | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) {
New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0
}
# Disable display and sleep mode timeouts
Function DisableSleepTimeout {
Write-Host "Disabling display and sleep mode timeouts..."
powercfg /X monitor-timeout-ac 0
powercfg /X monitor-timeout-dc 0
powercfg /X standby-timeout-ac 0
powercfg /X standby-timeout-dc 0
}
# Hide Taskbar Search button / box
Function HideTaskbarSearchBox {
Write-Host "Hiding Taskbar Search box / button..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0
}
# Hide Task View button
Function HideTaskView {
Write-Host "Hiding Task View button..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0
}
# Hide Taskbar People icon
Function HideTaskbarPeopleIcon {
Write-Host "Hiding People icon..."
If (!(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
}
Function SetDarkMode {
Write-Host "Setting Dark Mode & Colors..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Type DWord -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\DWM" -Name "ColorPrevalence" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\DWM" -Name "EnableWindowColorization" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\DWM" -Name "AccentColor" -Type DWord -Value 0xff484a4c
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\DWM" -Name "ColorizationColor" -Type DWord -Value 0xc44c4a48
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\DWM" -Name "ColorizationAfterglow" -Type DWord -Value 0xc44c4a48
}
# Uninstall OneDrive - Not applicable to Server
Function UninstallOneDrive {
Write-Host "Uninstalling OneDrive..."
Stop-Process -Name OneDrive -ErrorAction SilentlyContinue
Start-Sleep -s 3
$onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
If (!(Test-Path $onedrive)) {
$onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
}
Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
Start-Sleep -s 3
Stop-Process -Name explorer -ErrorAction SilentlyContinue
Start-Sleep -s 3
Remove-Item -Path "$env:USERPROFILE\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction SilentlyContinue
If (!(Test-Path "HKCR:")) {
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
}
Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
}
# Uninstall default Microsoft applications
Function UninstallMsftBloat {
Write-Host "Uninstalling default Microsoft applications..."
Get-AppxPackage "Microsoft.3DBuilder" | Remove-AppxPackage
Get-AppxPackage "Microsoft.BingFinance" | Remove-AppxPackage
Get-AppxPackage "Microsoft.BingNews" | Remove-AppxPackage
Get-AppxPackage "Microsoft.BingSports" | Remove-AppxPackage
Get-AppxPackage "Microsoft.BingWeather" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Getstarted" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftOfficeHub" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Office.OneNote" | Remove-AppxPackage
Get-AppxPackage "Microsoft.People" | Remove-AppxPackage
Get-AppxPackage "Microsoft.SkypeApp" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Windows.Photos" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsAlarms" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsCamera" | Remove-AppxPackage
Get-AppxPackage "microsoft.windowscommunicationsapps" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsMaps" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsPhone" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsSoundRecorder" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MixedReality.Portal" | Remove-AppxPackage
Get-AppxPackage "Microsoft.ZuneMusic" | Remove-AppxPackage
Get-AppxPackage "Microsoft.ZuneVideo" | Remove-AppxPackage
Get-AppxPackage "Microsoft.AppConnector" | Remove-AppxPackage
Get-AppxPackage "Microsoft.ConnectivityStore" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Office.Sway" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Messaging" | Remove-AppxPackage
Get-AppxPackage "Microsoft.CommsPhone" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftStickyNotes" | Remove-AppxPackage
Get-AppxPackage "Microsoft.OneConnect" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsFeedbackHub" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MinecraftUWP" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftPowerBIForWindows" | Remove-AppxPackage
Get-AppxPackage "Microsoft.NetworkSpeedTest" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MSPaint" | Remove-AppxPackage
Get-AppxPackage "Microsoft.ScreenSketch" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Microsoft3DViewer" | Remove-AppxPackage
Get-AppxPackage "Microsoft.RemoteDesktop" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Print3D" | Remove-AppxPackage
}
# Uninstall default third party applications
function UninstallThirdPartyBloat {
Write-Host "Uninstalling default third party applications..."
Get-AppxPackage "9E2F88E3.Twitter" | Remove-AppxPackage
Get-AppxPackage "king.com.CandyCrushSodaSaga" | Remove-AppxPackage
Get-AppxPackage "4DF9E0F8.Netflix" | Remove-AppxPackage
Get-AppxPackage "Drawboard.DrawboardPDF" | Remove-AppxPackage
Get-AppxPackage "D52A8D61.FarmVille2CountryEscape" | Remove-AppxPackage
Get-AppxPackage "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxPackage
Get-AppxPackage "flaregamesGmbH.RoyalRevolt2" | Remove-AppxPackage
Get-AppxPackage "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxPackage
Get-AppxPackage "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxPackage
Get-AppxPackage "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxPackage
Get-AppxPackage "Facebook.Facebook" | Remove-AppxPackage
Get-AppxPackage "46928bounde.EclipseManager" | Remove-AppxPackage
Get-AppxPackage "A278AB0D.MarchofEmpires" | Remove-AppxPackage
Get-AppxPackage "KeeperSecurityInc.Keeper" | Remove-AppxPackage
Get-AppxPackage "king.com.BubbleWitch3Saga" | Remove-AppxPackage
Get-AppxPackage "89006A2E.AutodeskSketchBook" | Remove-AppxPackage
Get-AppxPackage "CAF9E577.Plex" | Remove-AppxPackage
Get-AppxPackage "A278AB0D.DisneyMagicKingdoms" | Remove-AppxPackage
Get-AppxPackage "828B5831.HiddenCityMysteryofShadows" | Remove-AppxPackage
Get-AppxPackage "WinZipComputing.WinZipUniversal" | Remove-AppxPackage
Get-AppxPackage "SpotifyAB.SpotifyMusic" | Remove-AppxPackage
Get-AppxPackage "PandoraMediaInc.29680B314EFC2" | Remove-AppxPackage
Get-AppxPackage "2414FC7A.Viber" | Remove-AppxPackage
Get-AppxPackage "64885BlueEdge.OneCalendar" | Remove-AppxPackage
Get-AppxPackage "41038Axilesoft.ACGMediaPlayer" | Remove-AppxPackage
}
# Disable Xbox features
Function DisableXboxFeatures {
Write-Host "Disabling Xbox features..."
Get-AppxPackage "Microsoft.XboxApp" | Remove-AppxPackage
Get-AppxPackage "Microsoft.XboxIdentityProvider" | Remove-AppxPackage
Get-AppxPackage "Microsoft.XboxSpeechToTextOverlay" | Remove-AppxPackage
Get-AppxPackage "Microsoft.XboxGameOverlay" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Xbox.TCUI" | Remove-AppxPackage
Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -Type DWord -Value 0
}
# Uninstall Windows Media Player
Function UninstallMediaPlayer {
Write-Host "Uninstalling Windows Media Player..."
Disable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -NoRestart -WarningAction SilentlyContinue | Out-Null
}
# Install Linux Subsystem
Function InstallWSL2 {
Write-Host "Installing Linux Subsystem..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 1
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -NoRestart -WarningAction SilentlyContinue | Out-Null
Write-Host "Updating Linux Kernel..."
$wslUpdateSource = "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
$wslMsiArgs = @(
'/i',
$wslUpdateSource,
'/quiet',
'/norestart'
)
Start-Process -FilePath msiexec -ArgumentList $wslMsiArgs -NoNewWindow -Wait
if (!(Get-Command 'wsl' -ErrorAction SilentlyContinue)) {
Invoke-Reboot
} else {
wsl --set-default-version 2
}
}
# Install Hyper-V - Not applicable to Home
Function InstallHyperV {
Write-Host "Installing Hyper-V..."
If ((Get-WmiObject -Class "Win32_OperatingSystem").Caption -like "*Server*") {
Install-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null
}
Else {
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null
}
}
# Install Containers
Function InstallContainers {
Write-BoxstarterMessage "Enabling Containers"
Enable-WindowsOptionalFeature -FeatureName Containers -Online -NoRestart
}
# Unpin all Start Menu tiles - Not applicable to Server - Note: This function has no counterpart. You have to pin the tiles back manually.
Function UnpinStartMenuTiles {
Write-Host "Unpinning all Start Menu tiles..."
Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Include "*.group" -Recurse | ForEach-Object {
$data = (Get-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data").Data -Join ","
$data = $data.Substring(0, $data.IndexOf(",0,202,30") + 9) + ",0,202,80,0,0"
Set-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data" -Type Binary -Value $data.Split(",")
}
}
# Unpin all Taskbar icons - Note: This function has no counterpart. You have to pin the icons back manually.
Function UnpinTaskbarIcons {
Write-Host "Unpinning all Taskbar icons..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Name "Favorites" -Type Binary -Value ([byte[]](0xFF))
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Name "FavoritesResolve" -ErrorAction SilentlyContinue
}
# Setting Taskbar Options
Function SetTaskbar {
Write-Host "Setting Taskbar Icons to Large and Single Montior"
Set-BoxstarterTaskbarOptions -Size Large -Dock Bottom -Combine Always -MultiMonitorOff
}
# Setting Time Zone
Function SetTimeZoneCentral {
Write-BoxstarterMessage "Setting time zone to Central Standard Time"
& C:\Windows\system32\tzutil /s "Central Standard Time"
}
# Prefer IPV4 over IPV6. This allows for localhost passthru into WSL2
Function PreferIPV4 {
Write-BoxstarterMessage "Setting IPv4 prefered"
Write-BoxstarterMessage "Setting IPv4"
netsh int ipv6 delete prefixpolicy ::ffff:0:0/96 store=persistent
netsh int ipv6 add prefixpolicy ::ffff:0:0/96 51 4 store=persistent
Write-BoxstarterMessage "Setting IPv6 loopback"
netsh int ipv6 delete prefixpolicy ::1/128 store=persistent
netsh int ipv6 add prefixpolicy ::1/128 50 0 store=persistent
Write-BoxstarterMessage "Setting Native IPv6"
netsh int ipv6 delete prefixpolicy ::/0 store=persistent
netsh int ipv6 add prefixpolicy ::/0 40 1 store=persistent
Write-BoxstarterMessage "Setting 6to4"
netsh int ipv6 delete prefixpolicy 2002::/16 store=persistent
netsh int ipv6 add prefixpolicy 2002::/16 30 2 store=persistent
Write-BoxstarterMessage "Setting Teredo"
netsh int ipv6 delete prefixpolicy 2001::/32 store=persistent
netsh int ipv6 add prefixpolicy 2001::/32 5 5 store=persistent
Write-BoxstarterMessage "Setting ULAs"
netsh int ipv6 delete prefixpolicy fc00::/8 store=persistent
netsh int ipv6 add prefixpolicy fc00::/8 4 14 store=persistent
netsh int ipv6 delete prefixpolicy fd00::/8 store=persistent
netsh int ipv6 add prefixpolicy fd00::/8 3 13 store=persistent
Write-BoxstarterMessage "Setting v4compat"
netsh int ipv6 delete prefixpolicy ::/96 store=persistent
netsh int ipv6 add prefixpolicy ::/96 1 3 store=persistent
Write-BoxstarterMessage "Setting IPv6 site-local"
netsh int ipv6 delete prefixpolicy fec0::/10 store=persistent
netsh int ipv6 add prefixpolicy fec0::/10 1 11 store=persistent
Write-BoxstarterMessage "Setting 6bone"
netsh int ipv6 delete prefixpolicy 3ffe::/16 store=persistent
netsh int ipv6 add prefixpolicy 3ffe::/16 1 12 store=persistent
}
##################
# Utility Functions
##################
Function Get-SpecialPaths {
$SpecialFolders = @{}
$names = [Environment+SpecialFolder]::GetNames([Environment+SpecialFolder])
foreach($name in $names) {
$SpecialFolders[$name] = [Environment]::GetFolderPath($name)
}
$SpecialFolders
}
function Get-ChocoPackages {
if (get-command clist -ErrorAction:SilentlyContinue) {
clist -lo -r -all | Foreach {
$Name,$Version = $_ -split '\|'
New-Object -TypeName psobject -Property @{
'Name' = $Name
'Version' = $Version
}
}
}
}
function Start-Proc {
param([string]$Exe = $(Throw "An executable must be specified"),
[string]$Arguments,
[switch]$Hidden,
[switch]$waitforexit)
$startinfo = New-Object System.Diagnostics.ProcessStartInfo
$startinfo.FileName = $Exe
$startinfo.Arguments = $Arguments
if ($Hidden) {
$startinfo.WindowStyle = 'Hidden'
$startinfo.CreateNoWindow = $True
}
$process = [System.Diagnostics.Process]::Start($startinfo)
if ($waitforexit) { $process.WaitForExit() }
}
$SpecialPaths = Get-SpecialPaths
##################
# Start Customization of Settings
##################
# Downloads of non-chocolatey installed apps will go here (within system root)
$UtilDownloadPath = join-path $env:systemdrive 'Utilities\Downloads'
# Chocolatey places a bunch of crap on the desktop after installing or updating software. This flag allows
# you to clean that up (Note: this will move *.lnk files from the Public user profile desktop and your own
# desktop to a new directory called 'shortcuts' on your desktop. This may or may not be what you want..)
$ClearDesktopShortcuts = $True
$Configuration = @'
[
"DisableTelemetry",
"DisableWiFiSense",
"DisableWebSearch",
"DisableAppSuggestions",
"DisableLocationTracking",
"DisableFeedback",
"DisableAdvertisingID",
"DisableCortana",
"DisableSleepTimeout",
"HideTaskbarSearchBox",
"HideTaskView",
"HideTaskbarPeopleIcon",
"UninstallOneDrive",
"UninstallMsftBloat",
"DisableXboxFeatures",
"UninstallMediaPlayer",
"UnpinStartMenuTiles",
"UnpinTaskbarIcons",
"SetTaskbar",
"SetDarkMode",
"SetTimeZoneCentral",
"InstallHyperV",
"InstallContainers",
"InstallWSL2",
"PreferIPV4"
]
'@
# Chocolatey packages to install
$ChocoInstalls = @(
"firacode",
"cascadiafonts",
"googlechrome",
"obs-studio",
"obs-ndi",
"vlc",
"wox",
"7zip",
"lightshot",
"slack",
"discord",
"heidisql",
"termius",
"insomnia-rest-api-client",
"vscode",
"microsoft-windows-terminal",
"docker-desktop",
"wsl-ubuntu-2004"
)
$ManualDownloadInstall = @{
'MaxToSetup-2.1.5.exe' = 'https://files.maxto.net/releases/2.1.5/MaxToSetup-2.1.5.exe'
}
##################
# Windows Update
##################
Enable-UAC
Install-WindowsUpdate -AcceptEula
#--- Check 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
}
# Temporarily disable
Disable-MicrosoftUpdate
Disable-UAC
##################
# Configuration Tweaks
##################
$tweaks = @()
try {
$tweaks = $Configuration | ConvertFrom-Json
}
catch {
throw 'Unable to load configuration!'
}
if ($tweaks.count -gt 0) {
# Call the desired tweak functions
$tweaks | ForEach-Object {
Invoke-Expression $_
}
}
##################
# Manual Installs
##################
$FilesDownloaded = @()
If (-not (Test-Path $UtilDownloadPath)) {
mkdir $UtilDownloadPath -Force
}
Push-Location $UtilDownloadPath
# Manually downloaded software
Foreach ($software in $ManualDownloadInstall.keys) {
Write-Output "Downloading $software"
if ( -not (Test-Path $software) ) {
try {
Invoke-WebRequest $ManualDownloadInstall[$software] -OutFile $software -UseBasicParsing
$FilesDownloaded += $software
}
catch {}
}
else {
Write-Warning "File is already downloaded, skipping: $software"
}
}
# Kick off exe installs
Get-ChildItem -Path $UtilDownloadPath -File -Filter '*.exe' | Where {$FilesDownloaded -contains $_.Name} | Foreach {
Start-Proc -Exe $_.FullName -waitforexit
}
Pop-Location
##################
# Chocolatey Installs
##################
Write-Output "Installing software via chocolatey"
# Don't try to download and install a package if it shows already installed
$InstalledChocoPackages = (Get-ChocoPackages).Name
$ChocoInstalls = $ChocoInstalls | Where { $InstalledChocoPackages -notcontains $_ }
if ($ChocoInstalls.Count -gt 0) {
$ChocoInstalls | Foreach-Object {
try {
choco upgrade -y $_ --cacheLocation "$($env:userprofile)\AppData\Local\Temp\chocolatey"
}
catch {
Write-Warning "Unable to install software package with Chocolatey: $($_)"
}
}
}
else {
Write-Output 'There were no packages to install!'
}
##################
# Desktop Shortcuts
##################
if ($ClearDesktopShortcuts) {
$Desktop = $SpecialPaths['DesktopDirectory']
$DesktopShortcuts = Join-Path $Desktop 'Shortcuts'
if (-not (Test-Path $DesktopShortcuts)) {
Write-Host -ForegroundColor:Cyan "Creating a new shortcuts folder on your desktop and moving all .lnk files to it: $DesktopShortcuts"
$null = mkdir $DesktopShortcuts
}
Write-Output "Moving .lnk files from $($SpecialPaths['CommonDesktopDirectory']) to the Shortcuts folder"
Get-ChildItem -Path $SpecialPaths['CommonDesktopDirectory'] -Filter '*.lnk' | Foreach {
Move-Item -Path $_.FullName -Destination $DesktopShortcuts -ErrorAction:SilentlyContinue
}
Write-Output "Moving .lnk files from $Desktop to the Shortcuts folder"
Get-ChildItem -Path $Desktop -Filter '*.lnk' | Foreach {
Move-Item -Path $_.FullName -Destination $DesktopShortcuts -ErrorAction:SilentlyContinue
}
}
Enable-UAC
if (Test-PendingReboot) {
Invoke-Reboot
}
Write-Host -ForegroundColor:Green "Install and configuration complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment