Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yannduran/4d79818111b9d0d4cebda43ee1936e1b to your computer and use it in GitHub Desktop.
Save yannduran/4d79818111b9d0d4cebda43ee1936e1b to your computer and use it in GitHub Desktop.
My personal desktop Boxstarter script
Disable-UAC
# TODO: unpin Edge and Store and pin default apps
# SilentlyContinue — Don't display an error message continue to execute subsequent commands.
# Continue — Display any error message and attempt to continue execution of subsequence commands.
# Inquire — Prompts the user whether to continue or terminate the action
# Stop — Terminate the action with error.
$ErrorActionPreference = 'Continue'
$new_name = 'LSS-DEV-TEST'
$current_name = $env:computername
# Write-Host 'Current Computer Name:' $current_name
# Write-Host 'New Computer Name:'$new_name
if (!($current_name -eq $new_name))
{
Rename-Computer $new_name
}
Set-TimeZone -id 'AUS Eastern Standard Time'
$screenTimeoutMinutes = 30
powercfg /change monitor-timeout-ac $screenTimeoutMinutes
powercfg /change monitor-timeout-dc $screenTimeoutMinutes
powercfg /change standby-timeout-ac 0
powercfg /change hibernate-timeout-ac 0
# Install Boxstarter
Set-ExecutionPolicy RemoteSigned -Force
. { Invoke-WebRequest -useb https://boxstarter.org/bootstrapper.ps1 } | Invoke-Expression; Get-Boxstarter -Force
# Boxstarter installs itself using Chocolatey, so make sure this is set before Chocolatey installs anything else
$env:ChocolateyToolsLocation = Join-Path ([Environment]::GetFolderPath('CommonApplicationData')) 'chocolatey\tools'
[Environment]::SetEnvironmentVariable('ChocolateyToolsLocation', $env:ChocolateyToolsLocation, 'User')
Disable-BingSearch
Disable-GameBarTips
# Show taskbar buttons on taskbar where window is open
# Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name MMTaskbarMode -Value 2
# Hide taskbar search box
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Search -Name SearchboxTaskbarMode -Value 0
# Hide taskbar task view button
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowTaskViewButton -Value 0
# Hide Windows Ink Workspace button
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PenWorkspace -Name PenWorkspaceButtonDesiredVisibility -Value 0
# Disable 'Let apps use advertising ID'
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Value 0
# Disable 'Show me suggested content in the Settings app'
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338393Enabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353694Enabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353696Enabled -Value 0
# Disable 'Occasionally show suggestions in Start'
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338388Enabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
# Disable 'Show me the Windows welcome experience after updates and occasionally when I sign in to highlight what’s new and suggested'
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-310093Enabled -Value 0
# Disable 'Get tips, tricks, and suggestions as you use Windows'
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338389Enabled -Value 0
# Stop default apps from coming back
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEverEnabled -Value 0
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SilentInstalledAppsEnabled -Value 0
# Clean up the programs list
$microsoftAppsToUninstall =
'Microsoft.BingWeather',
'Microsoft.Microsoft3DViewer',
'Microsoft.Getstarted', # Start menu: Tips
'Microsoft.Messaging',
'Microsoft.MicrosoftOfficeHub',
'Microsoft.MicrosoftSolitaireCollection',
'Microsoft.MixedReality.Portal',
'Microsoft.MSPaint', # Start menu: Paint 3D
'Microsoft.OneConnect', # Start menu: Mobile Plans
'Microsoft.Print3D',
'Microsoft.SkypeApp',
'microsoft.windowscommunicationsapps', # Start menu: 'Mail' and 'Calendar'
'Microsoft.Xbox.TCUI', # Apps & Features: 'Xbox Live'
'Microsoft.XboxApp',
'Microsoft.XboxGameOverlay',
'Microsoft.XboxGamingOverlay',
'Microsoft.YourPhone',
'Microsoft.ZuneMusic',
'Microsoft.ZuneVideo'
# (See Get-StartApps and https://docs.microsoft.com/windows/application-management/apps-in-windows-10)
Get-AppxPackage -AllUsers |
Where-Object { $_.Publisher -notlike '*Microsoft*' -or $microsoftAppsToUninstall -contains $_.Name } |
Remove-AppxPackage
# -EnableShowHiddenFilesFoldersDrives
# -EnableShowProtectedOSFiles
# -EnableShowFileExtensions
# -EnableShowFullPathInTitleBar
# -EnableOpenFileExplorerToQuickAccess
# -EnableShowRecentFilesInQuickAccess
# -EnableShowFrequentFoldersInQuickAccess
# -EnableExpandToOpenFolder
# -EnableShowRibbon
Set-WindowsExplorerOptions `
-EnableShowHiddenFilesFoldersDrives `
-EnableShowFileExtensions `
-EnableShowFullPathInTitleBar `
-EnableExpandToOpenFolder `
-EnableShowProtectedOSFiles `
-DisableOpenFileExplorerToQuickAccess `
-DisableShowRecentFilesInQuickAccess `
-DisableShowFrequentFoldersInQuickAccess
# -Size Small
# -Dock Top
# -Combine Always
# -AlwaysShowIconsOn
# -MultiMonitorOn
# -MultiMonitorMode All
# -MultiMonitorCombine Always
Set-BoxstarterTaskbarOptions `
-Size Large `
-Dock Bottom `
-AlwaysShowIconsOn `
-MultiMonitorOn `
-MultiMonitorMode All
cinst git vivaldi -y
cinst visualstudio2019professional -y --package-parameters "--add Microsoft.VisualStudio.Component.Git"
Update-SessionEnvironment #refreshing env due to Git install
cinst -y visualstudio2019-workload-manageddesktop
cinst -y visualstudio2019-workload-netcoretools
cinst -y visualstudio2019-workload-azure
cinst -y visualstudio2019-workload-visualstudioextension
# foreach ($directory in ('DesktopDirectory', 'CommonDesktopDirectory')) {
# Get-ChildItem ([Environment]::GetFolderPath($directory)) -Filter '*.lnk' | Remove-Item
# }
# Needed for helper methods that edit settings files
. .\Utils.ps1
# Put my current .gitconfig in place
# Invoke-WebRequest 'https://gist.githubusercontent.com/jnm2/4b8d6caaf85157ea9763e22e41185f2d/raw/.gitconfig' -OutFile (
# Join-Path $env:USERPROFILE '.gitconfig')
Enable-RemoteDesktop
Update-Help
Enable-UAC
Enable-MicrosoftUpdate
Install-WindowsUpdate -acceptEula
function ReplaceSingleLineInTextFile(
[Parameter(Mandatory=$true)] [string] $Path,
[Parameter(Mandatory=$true)] [string] $OldLine,
[Parameter(Mandatory=$true)] [string] $NewLine) {
# Operate atomically by keeping file locked while reading and writing
$stream = [System.IO.FileStream]::new($Path, 'Open', 'ReadWrite', 'None')
try {
# Use the overload that enables passing keepOpen=$true so that the file is not closed if $reader is garbage-collected before the writing is done
$reader = [System.IO.StreamReader]::new($stream, [System.Text.UTF8Encoding]::new($false), $true, 4096, $true)
$lines = @()
$didReplace = $false
while ($null -ne ($line = $reader.ReadLine()))
{
if ($line -eq $OldLine) {
if ($didReplace) { throw 'More than one line matched.' }
$didReplace = $true
$line = $NewLine
}
$lines += $line
}
if (-not $didReplace) { throw 'No lines matched.' }
$stream.Position = 0
$writer = [System.IO.StreamWriter]::new($stream)
foreach ($line in $lines) {
$writer.WriteLine($line)
}
# Shorten the file if necessary to prevent padding to the original length with the original contents
$writer.Flush()
$stream.SetLength($stream.Position)
} finally { $stream.Dispose() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment