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
choco list -e procmon
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?
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"
}