Episerver 9 CertifiedMicrosoft Certified ProfessionalMicrosoft Certified Technology Specialist: .Net Framework 4, Web Applications

Using Chocolatey for your software installs

There have been a few times when starting a job at a new employer, the first thing you are tasked to do is to set up your computer - install the required software etc for your daily use. Even for home use, if you've ever had to reinstall windows, and set everything up again, it can be quite a long and tedious process.

I'm not a avid linux user, but the times I have used it and needed to install new software, the most you have to do is to use the built-in package managers to do the install. Most of the time it's as simple as

apt-get install <name-of-software-to-install>

(or whatever the package manager is on your distro of choice - yum etc.)

Windows doesn't have anything like that built-in. However, there is a piece of software called Chocolatey that aims to do the same.

A while ago, we had a couple of new starters join, and they spent most, if not all of the first day waiting for the required software to install. Not a very good use of time!

So, I took it upon myself to write a little windows powershell script that installed chocolatey, then installed the required software.

# Set the execution policy to allow, so that we can run commands from powershell.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; 

#Download the chocolately install script
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# Browsers
choco install googlechrome -y
choco install adblockpluschrome -y
choco install chrono-chrome -y
choco install firefox -y
choco install microsoft-edge -y

# Development
choco install vscode -y
choco install visualstudio2019community -y
choco install nodejs -y
choco install dotnetcore-sdk -y
choco install microsoft-windows-terminal -y
choco install sql-server-express -y

The (example) script above first sets the execution policy so that we can run commands from powershell, downloads the chocolatey installation script, then installs the required software.
The -y flag allows for automatic, unattended installs. So basically, run the script, and wait for everthing to download.

I decided to do the same for my home use as well. I created a script for all of the software that I use at home, and created myself a script. When I got a new laptop, this was the first thing I ran. I was up and running in no time!

A colleague saw this, and thought it was a good idea for new starters. So much, that they decided to expand upon it. He added the ability to download the source code for our projects from github/bitbucket, and perform some other initialisation tasks, so now when a new developer starts, they just have to input their github/bitbucket credentials, and all software and required source code will get get installed to the machine in a uniform/standardised manner!