Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I export the list of installed packages in a machine-readable format?

The only way I have seen to get a list of installed Chocolatey packages is with "choco version all" which outputs something like this:

You have SourceTree v1.9.1.1 installed. Version 1.9.6.1 is available based on your source(s).

You have sysinternals v2016.07.04 installed. Version 2016.08.29 is available based on your source(s).

Chocolatey can upgrade 5/9 packages. 0 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Can upgrade:
 - 7zip.install v16.02.0.20160811
 - chocolatey v0.10.0
 - sourcetree v1.9.6.1
 - 7zip v16.02.0.20160811
 - sysinternals v2016.08.29

For interactive console output that's fine, but for parsing to create a report it stinks. Is there some way I can get this info in XML or JSON or some standardized format, instead of having to parse the above myself?

like image 682
red888 Avatar asked Jan 20 '26 11:01

red888


1 Answers

Almost all chocolatey commands make use of the -r, --limitoutput, --limit-output switch, which means:

Limit the output to essential information

See this page for more information about what switches are available.

By doing choco version all -r you will get a much more parseable output. For example:

7zip|9.22.01.20130618|16.02.0.20160811|false
7zip.commandline|16.02|16.02.0.20160811|false
7zip.install|9.22.01.20130618|16.02.0.20160811|false
Atom|0.174.1|1.0.7|false
autohotkey.portable|1.1.22.01|1.1.24.01|false
BingDesktop|1.3.463.0|1.3.463.0|false
Boxstarter|2.4.209|2.8.29|false

However, you are asking about a command to export the list of "installed" packages.

choco list -lo -r

That command is documented as choco list --local-only. It runs in about one second and the output looks like this when choco list -lo -r:

7zip|9.22.01.20130618
7zip.commandline|16.02
7zip.install|9.22.01.20130618
Atom|0.174.1
autohotkey.portable|1.1.22.01
BingDesktop|1.3.463.0
Boxstarter|2.4.209
Boxstarter.Common|2.4.209
cake.portable|0.15.2
calibre|2.48.0
ccleaner|5.19.5633
chocolatey|0.10.0
chocolatey.extension|1.4.1
ChocolateyGUI|0.14.0-unstable0002
ChocolateyPackageUpdater|0.6.11.0
like image 127
Gary Ewan Park Avatar answered Jan 22 '26 02:01

Gary Ewan Park



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!