0

Is there any function to use instead of using this command in powershell script?

choco search --local-only $package.name

The function needs to return a list/array of objects with name and version if they exist, I want to use that in a powershell script.

Executing this command only returns an array of strings which is not clean to use

choco search --local-only $package.name

Thank you for any help.

Palle Due
  • 5,929
  • 4
  • 17
  • 32
Anouar BAKRI
  • 314
  • 2
  • 13

2 Answers2

2

One suggestion would be to use the Chocolatey PowerShell Module which you can find here:

https://www.powershellgallery.com/packages/chocolatey/0.0.71

This will return a PowerShell Object for the results of a search, which you can then enumerate, filter, etc as required.

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
2
Install-Module -Name chocolatey

Import-Module -Name chocolatey

This would be what you're looking for

Matthew
  • 1,412
  • 2
  • 20
  • 35