Skip to content

Instantly share code, notes, and snippets.

@maddindeiss
Last active June 25, 2018 09:27
Show Gist options
  • Save maddindeiss/26216624ead5a8300167e8f5da684ff6 to your computer and use it in GitHub Desktop.
Save maddindeiss/26216624ead5a8300167e8f5da684ff6 to your computer and use it in GitHub Desktop.
Windows 10 .Net DevBox
# Description: Boxstarter Script
# Common dev settings for desktop app development
# Test-Admin is not available yet, so use...
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell -ArgumentList "-noprofile -NoExit -file `"$PSCommandPath`"" -Verb RunAs
Exit
}
# http://boxstarter.org/InstallBoxstarter
# Installing from the web
# From a Administrator PowerShell, if Get-ExecutionPolicy returns Restricted, run:
if ((Get-ExecutionPolicy) -eq "Restricted") {
Set-ExecutionPolicy Unrestricted -Force
}
$_boxstarter_path = 'C:\ProgramData\Boxstarter\BoxstarterShell.ps1'
if (!(Test-Path $_boxstarter_path)) {
. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
}
# Then run: Boxstarter Shell as an Administrator
$cwd = "$(Get-Location)"
. $_boxstarter_path
cd "$cwd"
#--- Windows Features ---
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions
Disable-GameBarTips
Enable-RemoteDesktop
Update-ExecutionPolicy RemoteSigned
Update-ExecutionPolicy Unrestricted
Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All -NoRestart
if (Test-PendingReboot) { Invoke-Reboot }
# Install chocolatey
if (!(Test-Path 'C:\ProgramData\chocolatey\bin\choco.exe')) {
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
}
# Set up choco cache location to work around Boxstarter Issue 241
$chocoCache = (Join-Path ([Environment]::GetEnvironmentVariable("LocalAppData")) "Temp\ChocoCache")
New-Item -Path $chocoCache -ItemType directory -Force
#--- Windows Subsystems/Features ---
choco install -fy Microsoft-Hyper-V-All -source windowsFeatures
choco install -fy Microsoft-Windows-Subsystem-Linux -source windowsfeatures
choco install -fy -confirm openssh -params "/SSHAgentFeature"
choco install -fy python -params "InstallAllUsers=1"
choco install -fy jdk10 -params "source=false"
# Params:
# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
# Components:
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools
choco install -fy visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.NetCoreBuildTools;Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools;includeRecommended --passive --locale en-US"
refreshenv
# Seed an associative array of all locally installed chocolatey packages
$_installed_packages = @{}
choco list --limitoutput --localonly | % {
$line = $_.split('|')
$_installed_packages[$line[0].ToLower()] = $line[1]
}
function _cinst {
param([string] $package)
if (!$_installed_packages[$package.ToLower()]) {
Write-Host "Installing: $package"
cinst -y "$package"
}
else {
Write-Host "Already installed: $package"
}
}
# Seed a string variable with all locally installed PowerShell Gallery modules
$_installed_modules = Get-InstalledModule
function _Install-Module {
param([string] $module)
if ($_installed_modules -match "\b$module\b") {
Write-Host "Already installed: $module"
}
else {
Write-Host "Installing: $module"
Install-Module $module -Force
}
}
#--- Tools ---
_cinst sysinternals
_cinst git.install
if (Test-PendingReboot) { Invoke-Reboot }
_cinst nuget.commandline
_cinst jenkin
_cinst wixtoolset
_cinst vscode
_cinst 7zip.install
_cinst firefox
_cinst mssqlserver2012express
_cinst msbuild.extensionpack
Enable-MicrosoftUpdate
Install-WindowsUpdate -acceptEula
@maddindeiss
Copy link
Author

To start this script, start PowerShell as admin and run:

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File ".\win10_devbox.ps1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment