One of the things I end up having to do quite often is set up a windows workstation for my daily use. In many cases, customers prefer that we use a jump box or even a physical machine on their network/domain to access their servers. With all the various tools and things we have at our disposal these days, that can become very time-consuming. Recently I discovered Chocolatey, an open-source package manager for windows. This is a very lightweight way to automate the installation and configuration of software on a windows machine. In this article, we’ll take a look at a simple PowerShell script I use to set up chocolatey and install a given set of packages.
Chocolatey uses the concept of packages, similar to Nuget or PowerShell modules if you’re familiar with either of those. Packages are stored in a package repository that chocolatey pulls from to run the install. While you can create your own repository, for our purposes we will be using the community package repository provided by chocolatey. It is searchable and I’ve been pleasantly surprised how many of the tools I use are out there and maintained by the community. There are very few things I need to manage separately.
For this example, I’m using a text file with a list of packages to install. The package names were all retrieved from the gallery.
Installing the Packages
I said that this was lightweight and I meant it. The install for chocolatey is just a PowerShell script that you can download from their site. The script below is pretty straightforward. After installing chocolatey we get the list of packages we want to install and just loop through the list installing each one in order.
The other way I tend to use this is a lot is as I’m working and realize I need something, not on my box. Just today I had a need for PostMan. I could have gone to the site and downloaded the installer, stepped through the installer, etc. But instead, I used a three-word one-liner from a command prompt
Chocolatey is designed to improve the blood flow for WinOps people by automating the Windows desktop software management for a very sweet price, going from FREE to $16 a year. All you need to know is some PowerShell. Chocolatey is a delicious tool that does its thing very well. Give it a shot and let me know how it goes!