Chocolatey logo

Package Manager Chocolatey – by Caleb Fong aka @geekosupremo

Greetings fellow NosillaCastAways (still not sold on intracap).

Today I want to tell you all about a wonderful (mostly) Windows tool. It’s the package manager Chocolatey. In short, a package manager is a tool, to manage applications in a reproducible way. For example at my $DAYJOB I have to manage around fifty Windows desktops.

The built-in Windows Update is fine for keeping the Windows OS current but what about Firefox or LibreOffice or Python or Screen-to-gif? Each of these has its own update mechanisms but they’re all siloed into the individual apps. As the sysadmin, I want one place to keep all this managed and automated because no one wants to be hacked because there was that one old version of Chrome laying around.

The whole thing starts with a PowerShell script. This script pulls from either a large community repository or a local repository of software. This local repository may be a git repository, or it can be as simple as a shared folder on the network. But what does that do?

Well for one thing you can run a single line and install a whole mess of software. But more importantly for a sysadmin, with a single command, I can keep all of the installed software up to date and run it on a schedule, so you don’t ever have to touch that process again … at least until something breaks.

Now let’s talk installation and usage. First, you’ll want to go to https://chocolatey.org/, this is the main project/company page. In the main nav is the “Install Now” button, this gives the low down on installation and has links for other learning/training materials. The installation script works on every version of Windows going all the way back to Windows 7 using either the base installed PowerShell or the CMD interface. Now that the script is installed let’s get cracking on some usage examples.

As Powershell was highly informed by and designed to be familiar to *nix users, the syntax for the commands will feel very similar to things you hear on _Programming by Stealth_ and _Taming the Terminal_. A Chocolatey command starts with the choco command followed by a subcommand, of which there are several, and then an argument to the subcommand that makes the command useful.

For example choco search python

This will return a list of packages that include ‘Python’ in their name or description. In most cases, this is sufficient to determine which package you want, but if you need to know a little more about a package you can do: choco info [package-name] this will fetch the specific details about the named package. I would go on, but the latest version of the docs is an exceptional resource – Chocolatey docs. Plus most of the applications you’d want are using the name you’d expect. Should this CLI interface prove insufficient you can also go to the web interface of the community repository.

Now that you know what you want, installation is choco install [package-name]

OR if you want to do a set of packages
choco install [package-01] [package-02] [package-03]

Change your mind on that bit of software? Yank it out with a choco uninstall [package-name]

Want to schedule a weekly update? Put choco upgrade all -y into the script or command argument and Chocolatey will work it’s “magic” from the Task Scheduler!

There is a caveat emptor in this, choco needs to be run with Administrator rights, on Windows. On Mac and Linux it may be a little different, I don’t have a recent enough Mac to try this out, unfortunately.

There are two editions of Chocolatey, the Community (free and open source) and the Business also using the open source code, but with more good for business back end features and SLAs. The community edition is more than enough for just about anyone. If you are feeling generous or perhaps you find that you are getting good personal/developer value out of the project there is an individual pro plan that you can get.

With a little effort and some basic scripting skills, and I do mean basic because even I can write a script to accomplish these tasks I need, you also can have the joy of a terminal command to manage the essential and basic features of your Windows computer.

Leave a Reply

Your email address will not be published.

Scroll to top