Skip to content

Complex But Quick Windows Deployments With Boxstarter

Installing a Windows box is easy. Having it deployed the way we want it, not so easy. We need our business, development, and specialized tools installed just the way we like them. We also need the system configured just so. But it’s tedious work. Configuring Windows takes time. So does going to each website to get our software, then installing all of them. Don’t even bring up maintainable updating of all those applications.

But what if we could automate every task of setting up our perfect environment with a few commands and a simple script? With no need to even touch an installation wizard? No seriously, we can achieve this with Boxstarter!

Boxstarter is a utility that allows for highly complex Windows deployments. It uses the PowerShell scripting language, it’s own built-in functions and the Windows API to configure Windows with commonly known PowerShell commands. It also uses Chocolately package manager for downloading and updating software in a uniform way. Best of all, Boxstarter takes care of all the rebooting so you can deploy as an unattended install.

Installation And Deployment

Once you have installed your Windows Machine and setup the first user, you can deploy an installation script.

Here is an example of a basic Boxstarter script.

Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-RemoteDesktop

cinst fiddler4
cinst git-credential-winstore
cinst console-devel
cinst sublimetext2
cinst poshgit
cinst dotpeek

cinst Microsoft-Hyper-V-All -source windowsFeatures
cinst IIS-WebServerRole -source windowsfeatures

When supplied to Boxstarter, it will configure Window’s Explorer correctly, enable remote desktop, download a few applications, enable Hyper-V virtualization, and install IIS web server.

Boxstarter allows you to supply your script via the following:

  • Saving script as a package on any Nuget feed.
  • Saving a package to a network share or local media.
  • Save single text file to a text based HTTP resource.

Since it allows text based HTTP resources, we can do our remote installations sourcing our build script from a Github Gist. We want a more robust solution than our previous example so we can use my install script hosted here on Github.

Now that we have a script file to work with, we can download Chocolately, and Boxstarter. Run in an elevated PowerShell terminal and enter the following commands.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Re-open the shell. Now we need to install Boxstarter:

# For Powershell v3
. { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; Get-Boxstarter -Force

# For Powershell v2
iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1')); Get-Boxstarter -Force

All we have to do now is tell Boxstarter to run the script we posted to our Github gist with the Install-BoxstarterPackage command.

Note : When using gists, its important to source from the raw file.

Install-BoxstarterPackage -PackageName https://gist.githubusercontent.com/michaelrinderle/644b6f2c4817dafeeb6b8507f009c285/raw/b21052419036a957453f97b2d3554094c924afd3/install.ps1

That is it. All you have to do is sit back and let it do it’s thing.

Bonus : Cool commands for your installations

As an added bonus, here are some cool tricks for your install scripts.

Activate Windows Features.

cinst VirtualMachinePlatform -source windowsfeatures

Install Kali Linux to Window’s subsystem for Linux.

cinst Microsoft-Windows-Subsystem-Linux -source windowsfeatures 
Invoke-WebRequest -Uri https://aka.ms/wsl-kali-linux-new -OutFile ~/Kali.appx -UseBasicParsing
Add-AppxPackage -Path ~/Kali.appx
Remove-Item ~/Kali.appx

Remove Windows bloatware.

Get-AppxPackage king.com.CandyCrush* | Remove-AppxPackage

Disable Bing search results in Start Menu.

Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 0

Rename the computer.

$name = "Node1"
if ($env:computername -ne $computername) {
	Rename-Computer -NewName $name
}

Perform a Window’s update.

Install-WindowsUpdate -AcceptEula

Download Visual Studio Code with extentions.

cinst visualstudiocode 
code --install-extension esbenp.prettier-vscode
ode --install-extension ms-vscode.csharp

Set your Git information.

cinst git 
git config --global core.editor "code --wait"
git config --global user.name "michael rinderle"
git config --global user.email "michael|.|g|.|rinderle|@|gmail.net"

Updating your system

choco upgrade all

Michael has been a professional in the information technology field for over 10 years, specializing in software engineering and systems administration. He studied network security and holds a software engineering degree from Milwaukee Area Technical College with thousands of hours of self taught learning as well. He mainly writes about technology, current events, and coding. Michael also is the founder of Sof Digital, an U.S. based software development Firm. His hobbies are archery, turntablism, disc golf and rally racing.

Leave a Reply

Your email address will not be published. Required fields are marked *