Automatically Generating a Chocolatey Install Script

Have you ever dreaded formatting your computer because of all the software you know you’re going to have to re-install? Do you wish there was an easier way?

I’m looking at having to format one of the computers in our office and I want it have the same software that I have installed on my primary machine.

Since I use Chocolatey and WebPI to install most of the software on my computer, I was able to create a neat little Powershell script that should save me a lot of time with this task. 

Basically, this little bit of code generates a Chocolatey install script based on the following:

  • The current set of Windows features that you have enabled
  • Any software that you’ve installed through Windows Platform Installer (WebPI)
  • Any packages you’ve installed with Chocolatey.

It’s like taking a snapshot of parts of your software environment so you can re-install those parts later.

Here’s the script:

Running the script in Powershell spits out the following:

Save that off somewhere and use it as a starting point the next time you have to format your computer!

It’s probably a good idea to schedule the Powershell script to run periodically, and back it up, so you’ll always have a current version of your chocolatey install script.

The key, of course, is to always use Chocolatey and Web Platform Installer to install all of the software on your computer. But even if it’s not possible to install every piece of software with Chocolatey and WebPI, you can see from my install script above that it’s still possible to save a LOT of time with this technique.