My Profile Photo

Matthew Hodgkins Blog

❤️er of Platform Engineering, SRE, K8s, Golang, Observability and working with nice humans. Aussie living in the Netherlands.

Setup Windows 10 For Chef and PowerShell DSC Development

I am in the process of writing up some blog posts about working with PowerShell Desired State Configuration (DSC) and OpsCode Chef from a Windows Workstation / Windows Server perspective.

This first article will cover the steps required to setup a development environment for someone that is doing work with PowerShell Desired State Configuration (DSC) or OpsCode Chef.

We will be covering the following:

  • Installing git and poshgit - source control for your code and PowerShell integration for git
  • Installing VirtualBox - will be used with Vagrant to allow testing of DSC scripts and Chef recipes. I am using VirtualBox instead of Hyper-V as there are a ton of pre-build images for Linux and Windows available to download Atlas. Not having to make these yourself is a huge time saver.
  • Installing Vagrant - simple virtual machine creation. If you haven’t used Vagrant before I recommend checking out this video.
  • Installing ChefDK - the Chef Development Kit, includes knife, berkshelf, test-kitchen and Foodcritic
  • Installing Atom - awesome text editor that includes linters which will check your code for issues as you type

Once everything is installed, we will be customizing and setting up the following:

  • Customizing the PowerShell Profile to make it easier to work with git and set environment paths
  • Customizing Atom with some plugins including a ruby linter to validate the ruby we write in the chef recipes
  • Setting up ssh keys for use with git including configuring ssh agent, allowing us to push changes to git or work with private repositories
  • Downloading some vagrant plugins and adding some vagrant boxes
  • Configuring the knife.rb for working with Chef and creating a Berkshelf config.json file

Let’s get started.

Set Execution Policy and Install Applications

The first step is to install the tools and applications we need. The easiest way to do this is with a combination of Chocolatey and OneGet which is now built into Windows 10.

  • Open an Administrative PowerShell Prompt and do the following:

Customize Your PowerShell Profile

Now that you have installed PoshGit, it is a good idea to take a look at your PowerShell Profile.

You can make any sort of customization you like, but here are two suggestions for things to do in your profile:

  • Refresh the user and machine path environment variables. You will need to do this to use tools from the command line especially Atom, Chef and Vagrant.
  • Perform a Set-Location on the directory you use the most – for me this is my ProjectsGit directory where I keep all of my git repositories.

I have posted my PowerShell profile on GitHub as an example here.

My profile contains some useful functions for setting and reloading environment variables which I recommend you use in your own profile.

Path Environment Variable

With many of the tools used for developing with Chef on Windows, they will require a correctly configured Path environment variable.

If one of your tools is not working or you cannot run it from the command line, there is a good chance something is wrong with your Path variable. For example, to use Ruby from the command line after you install the ChefDK, you need to add ruby to the path variable.

If you are using the functions from my PowerShell profile from above, it is very easy to add Path environment variables:

Move PowerShell Profile to a Synced Drive (Optional)

If you move around to different machines, it is a good idea to move your your PowerShell Profile into a synced directory like Dropbox or OneDrive. From there you can create a symlink from the profile .ps1 in the synced path to the $PROFILE path.

  • Move your PowerShell profile from the $PROFILE location to the synced folder
  • Open an Administrative PowerShell Prompt
  • Run the following commands:

Symlink to PowerShell Profile

Configure Atom

Atom is a great text editor which I like to use for everything but working on PowerShell scripts. It is my editor of choice for modifying Chef recipes.

We can make it more powerful with some additional packages.

  • Open PowerShell
  • Run the following commands to install some handy Atom packages

Setup Git SSH Keys

You should be using source control for your Chef recipes and PowerShell scripts. Warren Frame has an excellent blog on the topic specific to PowerShell here.

Update 26/08/2016 - I created a more detailed guide on setting up Git SSH Keys on Windows. Check it out here: Ultimate PowerShell Prompt Customization and Git Setup Guide

Download Vagrant Boxes

Vagrant is an excellent way to test your DSC scripts or Chef recipes.

I like to use 2 boxes for my Windows 2012 R2 and Ubuntu testing with Chef/DSC. There are also several plugins that make using Vagrant even nicer.

We will install some plugins and pre-load the Vagrant boxes:

Configure Chef and Berkshelf

Next step is to get your chef user.pem file sorted out. Chef has a how-to guide for this here.

Once you have your .pem file, we will setup the knife.rb and the berkshelf config.json.

Customize the PowerShell ISE Theme (Optional)

The default theme for the PowerShell ISE is boring, lets spice it up with a theme. There is a great repository with PowerShell ISE themes located on GitHub.

To import the themes into the PowerShell ISE, go to Tools > Options > Manage Themes > Import.

PowerShell ISE Themes

Again, I would drop the theme into a synced folder so you can use it on all your machines.


With that, you should have your Windows machine setup PowerShell DSC and Chef development. Did I miss anything? Send me a tweet @matthodge and let me know!