Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chocolatey command to verify installed package regardless of chocolatey 1/2 version

Chocolatey reworked "choco list" command. Since version 2.0 it no more accepts --lo (=local) argument and every call is considered against local packages.

choco list --lo -e procmon

  • Chocolatey 1.1: it lists local package ("1 packages installed.")
  • Chocolatey 2.0: error ("Invalid argument --lo. This argument has been removed from the list command and cannot be used.")

choco list -e procmon

  • Chocolatey 1.1: it lists remote package ("1 packages found.")
  • Chocolatey 2.0: it lists local package ("1 packages installed.")

I use PowerShell scripts to maintain 1000 machines with various chocolatey versions. I need universal command to find if chocolatey package is installed. The command which works regardless on chocolatey version. How to do it?

like image 861
jing Avatar asked Oct 30 '25 05:10

jing


1 Answers

In both Chocolatey 1.* and 2.*, this should work:

choco list --lo --limit-output -e procmon

The --limit-output (or -r) in this case is restricting the output to a machine-readable delimited format (which I'd suggest using when parsing in PowerShell anyway, rather than matching on "x package found"). You could do something similar to the following:

$Result = choco list --lo -r -e vscode | ConvertFrom-Csv -delimiter "|" -Header Id,Version

Or, to just check that a package is installed:

if (choco list --lo -r -e procmon) {
  Write-Host "'procmon' is installed"
}
like image 178
James Ruskin Avatar answered Nov 01 '25 19:11

James Ruskin



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!