As an old-school Windows user since the XP days, I‘ve resigned myself to the countless hours lost manually installing, updating, and cleaning up software on my machines. Between hunting down installers online, tracking version release notes, adjusting PATH variables, and resolving odd dependencies…let‘s just say I really empathize with Sys Admins!
So when I first stumbled upon the Chocolatey package manager a few years ago, it felt like stumbling on a oasis after wandering the desert.🥳 After half a decade of usage, I can confidently say it has saved me thousands of hours in conjunction with BoxStarter for automated machine setups.
But what exactly is this Chocolatey thing I keep raving about? And why is it so useful? Let me show you…😉
What Exactly is Chocolatey?
At its core, Chocolatey brings the simplicity and power of modern package managers like APT and Homebrew into the Windows world. Just as Linux distributions standardized around APT, Chocolatey aims to provide a unified packaging format and centralized repository for Windows apps.
Over 9,775+ apps are available as Chocolatey packages – ranging from tiny open source utilities to massive enterprise installations like Visual Studio and ReSharper.
Chocolatey package growth over time [Source: Chocolatey Blog]
Chocolatey was created in 2011 by Rob Reynolds to solve his own frustrations with keeping software updated and consistent across team members. It grew exponentially through the early 2010‘s and now serves over 13 million downloads per month!
So how does it actually work under the hood?
Chocolatey utilizes the NuGet packaging infrastructure to bundle metadata like version, dependencies etc along with install / uninstall logic. It then manages these Chocolatey packages through a CLI interface and centralized repository.
Packages can run installers, execute scripts, tweak registry settings – whatever logic is needed for fully automated setup and configuration.
The open source Chocolatey client then handles caching, backups, logging etc around this process so you don‘t have to worry about the details. Think of it like a DJ expertly weaving different audio samples into a smooth music mix! 🎛️🎚️🎛️
Let‘s now dive into actually setting up Chocolatey on your own Windows devices.
Step-By-Step Guide to Install Chocolatey on Windows
The Chocolatey developers have optimized for a reliable self-service installation process that takes just 5 minutes for most Windows users.
I‘ll walk you through some best practice tips I‘ve learned over the years for avoiding hiccups. Let‘s quickly ensure we have the pre-requisites in place first.
Prerequisite Checklist
While Chocolatey is supported on Windows 7 and higher, I‘d recommend Windows 10 or 11 to start out for smoother experience. Also confirm that:
✅ Windows is up-to-date with latest patches
✅ Powershell v5+ is installed
✅ .NET Framework v4.0+ exists
✅ Windows Management Framework v5+ is present
✅ You have local admin privileges
Launch Powershell as Administrator
Now its time fire up your power shell 💪!
Right click on the Windows start menu Powershell icon and choose Run as Administrator.
Or you can press Windows key + X and pick the admin powershell option after clicking the windows icon menu.
Either option will prompt for elevated privileges if UAC is enabled.
Bypass Execution Policy
Alright time to run some magic commands that will download and install chocolatey for us! 🪄
But first a quick security check in Powershell…
Run:
Get-ExecutionPolicy
This will likely return Restricted
which prevents running local scripts. Let‘s go ahead and bypass that to keep things simple (Don‘t worry we‘ll restore restrictions right after installing chocolatey):
Set-ExecutionPolicy Bypass -Scope Process -Force
Install Chocolatey via Script
Now we‘re ready for the fun part! We‘ll install chocolatey by running its community installer script in this single line below:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://community.chocolatey.org/install.ps1‘))
Let‘s break that mouthful down:
- Again we start by temporarily bypassing execution policy for this process
- Adjust security protocol to support TLS 1.2+ connections
- Download Chocolatey installer script from community site
- Execute the downloaded installer script with
iex
alias
This will take just a minute or two to complete. Follow along the prompts and you‘ll see output like:
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/0.10.15
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting ‘Machine‘)
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere...
🎉 Awesome! Now we need to just wrap up some quick post-install steps.
Finish Chocolatey Setup
First let‘s validate the choco commands are working as expected:
choco -v
You should see version details indicating choco is ready to use from CLI!
Now we can go ahead and revert the execution policy back to default Restricted:
Set-ExecutionPolicy Restricted -Scope Process
This will prevent further scripts from executing again by default.
And that‘s it! You have successfully installed Chocolatey on your Windows machine – welcome to simpler software management! 👍
Using Chocolatey: Commands for Package Management
Now let‘s explore some of the common Chocolatey commands you‘ll use for core package operations…
Search Community Packages
Chocolatey hosts thousands of open source, freeware, and trial software packages at https://community.chocolatey.org. You can search directly from CLI:
choco search <keyword>
Let‘s try finding Visual Studio Code editor:
choco search visual studio code
We can see there is a community package called vscode
for installing VS Code.
Install Packages
Once you know the exact package name, install is pretty straightforward:
choco install <package_name>
For Visual Studio Code we would run:
choco install vscode
Chocolatey will automatically handle the entire installation process, no manual intervention needed!
You can also install multiple packages easily:
choco install git vscode docker-desktop
Upgrade Installed Packages
Keeping your apps fully updated is key for both features and security. Choco makes this very convenient:
choco upgrade all
The above will upgrade existing packages if newer versions are available. You can also target a specific package.
I recommend running upgrades weekly or after major Windows updates. Chocolatey will only apply relevant updates so it‘s safe to run frequently.
Uninstall Packages
When it‘s time to remove a package, cleanup is a breeze as well:
choco uninstall <package>
For example:
choco uninstall docker-desktop
Chocolatey will automatically track down and remove all installed files, registry entries, environment changes etc performed during installation of that package. This prevents clutter build up over time.
And that‘s the basics of Chocolatey package management! But there is so much more we can tap into…
Going Beyond Basics with Chocolatey
We‘ve really only scratched the surfaced of Chocolatey so far focused on its community package repository of FOSS apps.
Let‘s explore some more advanced capabilities that enable power users and enterprises to take it even further!
Configuration Files
Specifying every package with CLI flags for installs, upgrades etc becomes tedious fast.
Luckily Chocolatey allows defining all your package names and settings in XML, JSON, YAML config files instead!
Let‘s see a sample YAML config:
packages:
- name: git
- name: vscode
- name: jre8
You can then process everything in this file dynamically with a single choco command:
choco install -y packages.config
Where the -y
flag skips confirmation prompts.
This batch processing via config files makes Chocolatey great for automating large scale software rollouts.
Custom Packages
Chocolatey allows you to create custom packages for internal tools that don‘t have public community packages yet.
The choco new command generates starter files to build your own packages with PowerShell install/uninstall logic.
You can then host an internal Chocolatey server and seamlessly manage both public and private packages!
Comparison of Interfaces
So far we used the pure CLI for Chocolatey, which is great for scripting purposes. But there are some alternative interfaces available:
Chocolatey GUI: A desktop app for visual package management via GUI instead of CLI. Awesome to get started.
BoxStarter: Enhances Chocolatey for unattended installs along with desktop shortcuts after reboots. Extremely handy for developer workstations.
Chocolatey Central Management: Web UI for business central management of Chocolatey.
Evaluate to pick the best fit. CLI plus BoxStarter is my favorite combo currently.
Integration with Automation
A major value of Chocolatey is integration into broader IT infrastructure automation systems:
Puppet – Chocolatey provider allows Puppet to invoke package installs and management.
Ansible – Ansible‘s chocolatey module utilizes Windows hosts‘ Chocolatey for app deployments.
Chef – Chef cookbooks leverage Chocolatey resources for ensuring package states.
This infrastructure layer handles overall desired state configuration while Chocolatey provides robust package management capabilities.
Business Subscription
While open source Chocolatey is free and meets most needs for individuals, Chocolatey Software offers paid solutions for enterprise scale usage:
-
Chocolatey for Business – unlocks additional features around auditing, compliance, enhanced security etc. Great for regulated orgs.
-
Chocolatey Central Management – web UI with role based access control, reporting APIs etc tailor made for large businesses
Let‘s hear from an actual SysAdmin using Chocolatey how it benefits them:
"We manage over 5000 endpoints across the organization. Chocolatey paid tiers coupled with SCCM integration have been instrumental in ensuring we have visibility into standardized software states for all devices and users. This reduces support costs and minimizes risk exposure from shadow IT or unauthorized tools"…Mark Willis, IT Director at Fabrikam Inc.
Hope this gives you a taste of business use cases! For open source needs, community edition has you covered with depth.
How Does Chocolatey Stack Up Against Competition?
Although Chocolatey pioneering Windows package management over a decade ago, Microsoft has bolstered native options recently like Winget and Windows Package Manager.
Do these make Chocolatey obsolete or less relevant? Let‘s analyze the competitive landscape.
Chocolatey still dominates Windows package management [Source: Datanyze]
Microsoft Winget
Winget as an apt-like package manager for Windows 10 and 11 has fantastic promise. Core advantages:
✅ Built directly into Windows so no setup needed
✅ Containerized installers enhance security
❌ Currently has much smaller package ecosystem vs. Chocolatey
Overall Winget fills a great niche but has a long road ahead to catch up with Chocolatey maturity. Co-existence is win-win for users!
Windows Package Manager
The preview Windows Package Manager framework aims to standardize Windows apps packaging to enhance security and reliability. This doesn‘t compete directly with tools like Chocolatey today but can provide strong base platform improving the ecosystem.
We expect both Chocolatey and Winget to eventually leverage Windows Package Manager under the hood for delivery optimization, conflicts resolution etc. Very exciting things ahead!
Key Takeaways and Next Steps
Let‘s recap key learnings from our thorough exploration of Chocolatey package management on Windows:
✅ Chocolatey simplifies Windows software management through 9000+ public packages
✅ Robust CLI for automation plus GUI options for new users
✅ Integrates well into infrastructure configuration tools like Puppet, Ansible etc
✅ Paid tiers offer features for enterprise IT management needs
✅ Co-exists well with Microsoft‘s own Winget and Windows Package Manager
I challenge you to try it out and see first hand the hours upon hours you save once set up. Especially effective combo with BoxStarter for repeated developer machine provisioning.
What questions come to mind about Chocolatey? Ask below in comments and myself or the helpful community members will assist! 😊