Easy PC rebuilds with Chocolatey

One of the things that I’ve always been interested in is automation, and being able to reproduce a ‘known state’ reliably and consistently. This applies at work when building servers or workstations thanks to tools like SCCM and Fog, and should be in your grasp at home or in even the smallest office, thanks to Chocolatey.

Not to make a fine point of it, between my last post and this one I’ve rebuilt my PC, installing windows from scratch and all my applications, prepared breakfast for my partner and myself, started some laundry, and dealt with the cat pulling the net curtains down in my study.

The easiest part of that was the computer rebuild, with help from Chocolatey. Remember having to spend ages downloading and installing applications when you had to reinstall your Windows PC at home? Remember looking at Linux and (whatever other opinions on Linux you might or might not have) being envious of package managers like apt-get?

Well this is now perfectly possible in Windows. To reinstall my PC today I:

  1. Made sure my backups of my documents folders were up-to-date (which these days is just a matter of making sure your cloud sync tool of choice is working).
  2. Formatted my system disk and re-installed windows with a bootable windows 10 memory stick.
  3. Installed my password manager of choice in Edge so I could get into my accounts.
  4. Ran “rob_choco_install.ps1” from an administrative Powershell command line.
  5. That’s it.
  6. Well not entirely. I’m still not happy that apps from the windows store install without my consent on a new PC and take effort to tidy up. If you want us to use the store, here’s a suggestion Microsoft: Genuinely compelling applications and content. Just a thought.

So what’s “rob_choco_install.ps1” then? Simple, a bit of powershell that contains the instructions below:

Set-ExecutionPolicy AllSigned; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))

choco install -y malwarebytes
choco install -y opendns-updater
choco install -y spotify
choco install -y itunes
choco install -y office365proplus
choco install -y adobe-creative-cloud
choco install -y steam
choco install -y uplay
choco install -y chrome
choco install -y chromium
choco install -y palemoon
choco install -y firefox
choco install -y vlc
choco install -y notepadplusplus
choco install -y windirstat
choco install -y adblockplus-firefox
choco install -y adblockpluschrome
choco install -y plexmediaserver
choco install -y plex-home-theater
choco install -y handbrake.install

So the first line installs Chocolatey from Chocolatey.org’s server. The subsequent lines install about 90% of all the applications I use on this computer as Application Packages. An application package is an application, plus installation steps for Chocolatey to use to install the application. I could have all those application packages on one line but I personally prefer to split them up, but if you wanted, one line like the example below would be just as valid as my example above.

choco install -y windirstat vlc firefox notepadplusplus steam uplay

Sure, some of these packages are just tiny little applications, but there are some heavy hitters in there too, for example:

choco install -y office365proplus
choco install -y adobe-creative-cloud

Yes, those are full installers for the Office 365 full ‘Click to Run’ package, and Adobe’s Creative Cloud manager. So that’s the full version of Microsoft Office and Adobe’s Creative Cloud suite, along with other applications like iTunes, Steam, my many web browsers, all installed automatically while I was off poaching eggs and asparagus for breakfast.

This means that if you have good backups of your data (and if not, why not), a good password manager (and again, if not why not) and the will to try something new, your computer at home can be rebuilt from scratch in slightly less than an hour without you having to do much of anything except log in.

What about security? Good question. The free to use open source package repository does make checks of the packages but you should still carry out your own due diligence. Luckily, there is a virus scanning service in the opt-in paid for subscription versions of Chocolatey, along with the ability for all of us to look at the packages we’re installing and what they do before installing them.

Office 365 Package on Chocolatey

For example, where I mention Office 365 ProPlus above, it would surely be a problem to install that from a compromised source. Luckily, I can go to the package repository, search for ‘office365proplus’ and see what the package contains and does. I can expand the ‘files’ option and inspect the files and notice the download source is a Microsoft.com site, and I can check the configuration file to ensure nothing suspicious is happening… and I can do this for all the packages in the repository.

In my opinion and with some caveats, this is a good option for security. While it’s fairly easy to get reasonable providence for packages like Microsoft Office and Adobe Creative Cloud, it might be more difficult for less computer savvy people to wade through deceptive ads when they go online and just search for “Malwarebytes” in their new computer’s default web browser…

malwarebytes search
“I just went on the Internet, and I found this”

What about keeping it all updated? Good question. Many of these applications will update themselves once they’re installed anyway. Steam and Spotify are good examples that lots of people will be familiar with on a home PC of how this can work.

For everything else installed through Chocolatey, it’s still not too bad.

Choco upgrade all

Yes, running that from a powershell command line (or if you’re feeling fancy, a powershell job in your task scheduler) will update all applications installed via Chocolatey to the latest version published in the Chocolatey repository.

What about removing old software? Again, not too bad…

Choco uninstall package-name

What about a GUI to manage this with? Ah yes. I have to admit I felt the same way when I started playing with Chocolatey, though I find myself using it less and less now, but still, you’ve got options.

Choco install -y chocolateygui

… will install a graphical interface for Chocolatey. This really only allows you to do the basic stuff such as install, upgrade, remove and search for packages. Luckily, that’s about 90% of what most people want to do.

Chocolatey Gui allows you to do basic installation and management of packages.

What about business use? I could tell you my thoughts now, but this article is getting long and it’s time to go to the gym, so wait for part 2.

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.