Save time installing stuff with chocolatey

I have been using chocolatey for setting up my development environment and just installing things in general for a while now.  I was not really noticing any difference from just double clicking a bunch of MSI files other than the silent install option until recently.

This little script leverages chocolatey to install all my necessary software for development in a couple minutes and without me sitting through a couple hours of waiting for progress bars to complete.

The steps:

First let's open up an admin powershell and grab all my packages from my existing environment using chocolatey list command and the --local-only argument into a variable:

$chocodata = [System.Collections.ArrayList](choco list --local-only \
| ForEach-Object { $_.split(" ")[0] })

The last result of choco list is the number of packages which is why we don't need the last row from choco data.  I remove it using removeAt which is available to me because we convert the list results to a system.collections.arraylist.

$chocodata.removeAt($chocodata.count - 1)

Now all there is to be done is loop thru the array and invoke cinst:

$chocodata | Foreach-object { choco upgrade $_ }

Now all my apps have been upgraded to the latest versions available.  If I want to install the same packages in a different VM I just need to move the content of $chocodata to a text file and do the same as above but looping through the lines of the text file.

 


This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.