Exploring the Find-Package Cmdlet from the PowerShell version 5 Preview OneGet Module

While presenting on the OneGet Module in the preview version of PowerShell version 5 for the Mississippi PowerShell User Group last week I discovered a couple of things about the Find-Package cmdlet that I wanted to share.

The first thing is wildcards don’t work with the name parameter:

2014-04-12_20-49-23

That’s seems to be because they’re already performing a wildcard search as I’ll search for ‘Java’ in the following example and notice that none of the packages are that exact name. Some contain other words before the word Java, some contain words afterwards, and some contain words before and afterwards so searching for Java effectively searches for *Java*. You’ll also notice the search was not case sensitive:

2014-04-12_20-47-36

You may think that the previous search contains all of the results for packages with Java in their name? That assumption would be incorrect. Adding the -MinimumVersion parameter returns more results and you would think it would return fewer results:

2014-04-12_20-57-08

You might think that you’ll out smart it and specify all versions from .1 to 100 to return everything, but that won’t return anything:

2014-04-12_20-58-51

I thought this may be because MinimumVersion might want an integer, but checking the help for that parameter shows it expects a string:

2014-04-12_21-01-14

Specifying 0 or even 0.1 returns what you would expect:

2014-04-12_21-03-43

There’s an easier way to accomplish the task of returning all versions though, by using the -AllVersions parameter:

2014-04-12_21-05-33

A few days ago I meantioned being overwheled if you ran the Find-Package cmdlet without any parameters. That returned 1751 packages:

2014-04-12_20-12-10

Adding this newly discovered -AllVersions parameter returns 7691 packages:

2014-04-12_20-13-24

There’s a -IncludePrereleaseVersions parameter, but adding that parameter returned the same number of packages as the previous command:

2014-04-12_20-14-28

There’s also a -Hint parameter which is interesting but also a bit mysterious and I’m still working on figuring out this parameter as it’s not as self explanatory as the others:

2014-04-12_21-27-11

2014-04-12_21-30-47

I’ve written several blog articles about the OneGet module during the past week so be sure to take a look at them for more information about the new features in the preview version of Powershell version 5.

µ

1 Comment

  1. Stefan StrangerS

    Hi Mike,

    When doing some tests with the Hint Parameter it seems that using that parameter is using the Skip Token System Query Option in the query to the PackageSource.

    http://msdn.microsoft.com/en-us/library/dd942121.aspx

    But I only see the skiptoken when not using in combination with the Name parameter.

    This needs some more clarification I guess 🙂

    /Stefan

    Reply

Leave a Reply

%d bloggers like this: