Using Windows Powershell and Chocolatey to quickly setup a new dev desktop environment

I’ve become a huge fan of Chocolatey. I historically have a Linux developer background and I got spoilt by apt so it always had me upset that there was no unified way in Windows of installing and keeping track of various utilities a developer would find useful in day to day life.

I had some experience in Linux shell scripting in my past, but really got into it while building data cleansing scripts using tools like curl, grep and sed for an e-commerce startup I used work for. While I did recognize immediately how powerful mastery of Powershell would offer a Windows developer like myself, it was only in the last year or so I have had the opportunity for field work to hone this (and I am still, by no means, a master of this). I hope soon to have some deeper articles on Powershell, especially now that Powershell Core is maturing and makes it a contender for cross-platform scripting in a manner that may take on the likes of traditional shell scripting shells like bash.

For now though, let’s start at the beginning of any developer’s journey: Getting your dev workstation setup. If you’re anywhere close to my use case, where I use a Mac but spin up new Windows VMs frequently to either isolate different clients’ VPN requirements or keep their streams of work separate, this can be a task in repetition.

Thankfully there’s a simple script I wrote, that eases this into one Powershell script. The initial code I sanitised for release is simple enough to paste in this article, but I plan to update it for more complex developer environment requirements, so you should clone my EasyDevWorkstation Github repository to get these updated scripts later on.

The following lines of script, taken from this repo, when run from an administror-mode Powershell prompt, will do the following:

  1. Set the Execution Policy of the system to RemoteSigned to allow the installation of Chocolatey, and in turn allow Chocolatey scripts to install software
  2. Download and Install Chocolatey
  3. Install via Chocolatey the following
    1. Git, because you need version control from the beginning
    2. Google Chrome browser, because we’re not all Edge and IE fans
    3. The latest available version of Powershell (in case you are running an older OS like Windows Server 2008 R2, Chocolatey I think requires at least one version higher than the base install version)
    4. Visual Studio code, which has been growing in popularity (and extensions) to allow really simple to really powerful scenarios for coding solutions, and has good Git integration
    5. SQL Server Management Studio, because most common developer scenarios require connecting to SQL Server databases at some point.

Here’s the script:

Set-ExecutionPolicy RemoteSigned
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
refreshenv
choco install -y --allow-empty-checksums git GoogleChrome powershell visualstudiocode sql-server-management-studio

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