Apt-Get has come to Windows. Just as the Greek gods were renamed when they were adopted by the Romans, Linux’s apt-get on Windows is known as “Chocolatey”.

If you are a developer, you can think of Chocolatey as Nuget for your machine. If you are unfamiliar with nuget or apt-get, Chocolatey is simply an independent repository of software installation scripts, allowing you to install apps such as Firefox, Visual Studio, or Resharper on your machine with a single command line. Even better, you can create your own powershell scripts that can install a multitude of apps in unattended bliss.

For example, if you wanted to setup a new development workstation, a script like the one shown below would eliminate a lot of boring desktop admin work, installing all your favorite development tools automatically. It even installs Chocolatey for you. Checkout chocolatey.org for the full list of apps available and their command lines.

NOTE: the command “cinstm” means “install if it isn’t already installed”

NOTE: don’t forget to set your script execution policy to Unrestricted before you run this powershell script
(from a command line run in Admin mode)

Set-ExecutionPolicy Unrestricted

Here is the powershell script, which you can save as “SetupDevEnviron.ps1”:

# This script was based off these samples: https://github.com/chocolatey/chocolatey/wiki/DevelopmentEnvironmentSetup

function Install-NeededFor {
   [string] $packageName = ''
  ,[bool] $defaultAnswer = $true
  if ($packageName -eq '') {return $false}
  $yes = '6'
  $no = '7'
  $defaultAnswerDisplay = 'Yes'
  $buttonType = 0x4;
  if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104;}
  $answer = $msgBoxTimeout
  try {
    $timeout = 10
    $question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
    $msgBox = New-Object -ComObject WScript.Shell
    $answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
  catch {
  if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
    write-host "Installing $packageName"
    return $true
  write-host "Not installing $packageName"
  return $false

#install chocolatey
if (Install-NeededFor 'chocolatey') {
  $downloadUrl = 'http://chocolatey.org/install.ps1';
  $webclient = new-object net.webclient;
  $webclient.proxy.credentials = [system.net.credentialcache]::DefaultNetworkCredentials;
  $webclient.downloadstring('http://chocolatey.org/install.ps1') | iex;

Write-Host 'Installing utilities...'
cinstm Firefox
cinstm GoogleChrome
cinstm 7zip.install
cinstm Console2
cinstm fiddler

Write-Host 'Installing Visual Studio...'
cinstm VisualStudio2012Ultimate

Write-Host 'Installing Visual Studio packages...'
if (Install-NeededFor 'VS2012 Update 2', $false) {
	cinstm Dogtail.VS2012.2
cinstm resharper
cinstm NugetPackageManager
cinstm nuget.commandline
cinstm tfs2012powertools
cinstm tfsSidekicks2012

« »