How to provision a Windows environment (using Boxstarter and Chocolatey)

Boxstarter leverages Chocolatey packages to automate the installation of software and create repeatable, scripted Windows environments. Chocolatey makes installing software very easy with no user intervention. Boxstarter enhances Chocolatey’s functionality and provides an environment that is optimized for installing a complete environment on a fresh OS install, as well as some other specific scenarios.

Write a script

Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
Install-WindowsUpdate -AcceptEula

cinst git.install putty.install -y
cinst conemu notepadplusplus.install vim xplorer2 -y

See WinConfig for more commands. Other examples, see Provisioning a New Development Machine With BoxStarter and Automating Windows environments’ setup with Boxstarter and Chocolatey packages.

Note that recent versions of chocolatery require autoconfirm switch. See Rename config confirmation setting.

Save the script into your dotfiles repo.

Install the script

  • Either from URL. Copy-paste script to gist, get the raw URL and:
iexplore http://boxstarter.org/package/nr/url?URLtoScript
# open admin console
powershell -Command "Start-Process %comspec% -Verb runAs"

# either unzip from http://boxstarter.org/ + Setup.bat or
cinst boxstarter

# then install package by script or package name (after compiling the script)
Install-BoxstarterPackage -PackageName PackageNameOrScriptPath

# use `-DisableReboots` to disable any possible pending reboots (due to package installation)

Optionally you can install remotelly:

# as admin on the remote/target machine
Enable-PSRemoting -Force

# on the machine where boxstarter is installed
$cred=Get-Credential
Install-BoxstarterPackage -ComputerName MyTargetMachine -PackageName PackageNameOrScriptPath -Credential $cred
  • Or from network share. Need to setup network share with boxstarter. Install boxstarter locally (see above), then:
# on boxstarter shell (to create network share of $Boxstarter.BaseDir)
Set-BoxstarterShare BoxShare

# optionally, if you want to make share portable (eg: linux share)
Copy-Item $Boxstarter.BaseDir \\Linuxhost\BoxShare -Recurse

# finally on the remote/target machine
\\mycomputer\BoxShare\Boxstarter.bat PackageNameOrScriptPath

Optionally you can also compile the script into a package, available in $Boxstarter.LocalRepo which you can use as a private package server/repo:

New-PackageFromScript -Source MyScript.ps1 -PackageName MyPackage
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s