Choco-tastic package export and restore!

Manage your list of choco packages before your reinstall with some useful commands.

Chocolatey was a game changer for Windows users when it was released, it brought the ease of package managers that most unix users have enjoyed over the years. Personally, just having a single command (choco upgrade -y all) to upgrade them was a boon.

However, the story for exporting and importing your existing packages was a bit sketchy. So to save your reinstalls from pain, here’s two Notes to help you export your installed packages in a format that you can pipe to a powershell file to execute later.

There’s two different approaches, install the exact version you’ve got installed now or get the latest version from the sources by omitting the version in the output.

$ choco list -lo -r -y | % { "choco install -y " + $_.Replace("|", " -version ")}
Example output:
choco install -y agentransack -version 2019.2929
choco install -y audacity -version 2.3.3
choco install -y beyondcompare -version 4.3.4.24657
choco install -y brave -version 1.5.122
choco install -y chocolatey -version 0.10.15
choco install -y chocolatey-core.extension -version 1.3.5.1
choco install -y chocolatey-dotnetfx.extension -version 1.0.1
choco install -y chocolatey-windowsupdate.extension -version 1.0.4
choco install -y ConEmu -version 19.10.12.0
choco install -y datagrip -version 2020.1

$ choco list -lo -r -y | % { "choco install -y " + $_.Split("|")[0]}
Example output:
choco install -y agentransack
choco install -y audacity
choco install -y beyondcompare
choco install -y brave
choco install -y chocolatey
choco install -y chocolatey-core.extension
choco install -y chocolatey-dotnetfx.extension
choco install -y chocolatey-windowsupdate.extension
choco install -y ConEmu
choco install -y datagrip

With the choco list command, we ask choco to pull in only the locally installed packages (-lo) and limit that info to just the essential bits (-r) and just confirm all the prompts (-y) cause aint nobody got time for that.

There is a caveat though, it includes the dependencies of the main packages in that list (I’ve left the default Chocolatey packages in the example above).

Related Articles

Post is 1704 days old, comments have been disabled.