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:

1Find-Package -Name *Java*

2014-04-12_20-49-23.png

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:

1Find-Package -Name Java

2014-04-12_20-47-36.png

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:

1Find-Package -Name Java -MinimumVersion 7.0

2014-04-12_20-57-08.png

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:

1Find-Package -Name Java -MinimumVersion .1 -MaximumVersion 100

2014-04-12_20-58-51.png

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

1help Find-Package -Parameter MinimumVersion

2014-04-12_21-01-14.png

Specifying 0 or even 0.1 returns what you would expect:

1Find-Package -Name Java -MinimumVersion 0 -MaximumVersion 100

2014-04-12_21-03-43.png

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

1Find-Package -Name Java -AllVersions

2014-04-12_21-05-33.png

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

1(Find-Package).count

2014-04-12_20-12-10.png

Adding this newly discovered AllVersions parameter returns 7691 packages:

1(Find-Package -AllVersions).count

2014-04-12_20-13-24.png

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

1(Find-Package -AllVersions -AllowPrereleaseVersions).count

2014-04-12_20-14-28.png

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:

1Find-Package -Hint Oracle -AllVersions

2014-04-12_21-27-11.png

1Find-Package -Hint 'VideoLAN Organization'

2014-04-12_21-30-47.png

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.

µ