Skip to content

Find-PSResource Does Not Properly Evaluate/Compare Available Package Versions Against Specified Version #1782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dwillis77 opened this issue Jan 24, 2025 · 1 comment
Labels
Issue-Bug Something isn't working

Comments

@dwillis77
Copy link

dwillis77 commented Jan 24, 2025

Steps to reproduce

  1. Run a Find-PSResource cmdlet with -Version param specified that should show all versions from a specific version and above.
    Find-PSResource VMware.PowerCLI -Version "[6, ]"
  2. See that the output does not necessarily include all newer available versions (depending on the input version given).

Expected behavior

In this example scenario, the output should have produced lines for all versions of PowerCLI from v6.x up through v13.x which is the current. The old Find-Module cmdlet with -AllVersions param reflects this behavior:

PS > Find-Module -Name 'VMware.PowerCLI' -AllVersions

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
13.3.0.24145081      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.2.1.22851661      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.2.0.22746353      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.1.0.21624340      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.0.0.20829139      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.7.0.20091289      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.6.0.19610541      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.5.0.19195797      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.4.1.18769701      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.4.0.18633274      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.3.0.17860403      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.2.0.17538434      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.1.0.17009493      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.0.0.15947286      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.5.0.14912921      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.4.0.14413515      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.3.0.13990089      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.2.0.12780525      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.2.0.12483598      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.1.0.11289667      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.0.0.10380590      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.2.0.9372002       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.1.1.8827524       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.1.0.8403314       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.0.0.7895300       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.4.7155375        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.3.6870460        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.2.6268016        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.1.5377412        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...

Actual behavior

Instead we only see lines for the v6.x versions.

PS > Find-PSResource VMware.PowerCLI -Version "[6, ]"

Name            Version       Prerelease Repository Description
----            -------       ---------- ---------- -----------
VMware.PowerCLI 6.5.4.7155375            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.3.6870460            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.2.6268016            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.1.5377412            PSGallery  This Windows PowerShell module contains VMware.PowerCLI

We could run the same command again but with the value 10 inside the version string this time, instead of 6, to confirm that there are in fact newer versions available.

PS > Find-PSResource VMware.PowerCLI -Version "[10, ]"

Name            Version         Prerelease Repository Description
----            -------         ---------- ---------- -----------
VMware.PowerCLI 13.3.0.24145081            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.2.1.22851661            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.2.0.22746353            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.1.0.21624340            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.0.0.20829139            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.7.0.20091289            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.6.0.19610541            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.5.0.19195797            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.4.1.18769701            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.4.0.18633274            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.3.0.17860403            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.2.0.17538434            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.1.0.17009493            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.0.0.15947286            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.5.0.14912921            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.4.0.14413515            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.3.0.13990089            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.2.0.12780525            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.2.0.12483598            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.1.0.11289667            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.0.0.10380590            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.2.0.9372002             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.1.1.8827524             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.1.0.8403314             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.0.0.7895300             PSGallery  This Windows PowerShell module contains VMware.PowerCLI

Error details

I'm assuming this has something to do with it not properly interpreting or "sorting" the version field. It appears to be sorting in lexicographical order instead of numerical order (so it thinks 10.x is lower than 6.x since 10 starts with a 1) - that's just a guess based on the behavior I've seen but I could be wrong.

Also I would add that the behavior has been reproduced on both WindowsPowerShell (v5.1) as well as PowerShell (v7).

Please let me know if any additional info is needed.

Thanks!

Environment data

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.1.0      Microsoft.PowerShell.PSResourceGet  {Compress-PSResource, Find-PSResource, Get-InstalledPSReso...

Key   : PSVersion
Value : 5.1.19041.5369
Name  : PSVersion


Key   : PSEdition
Value : Desktop
Name  : PSEdition


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions


Key   : BuildVersion
Value : 10.0.19041.5369
Name  : BuildVersion


Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion

Visuals

Image

@dwillis77 dwillis77 changed the title Find-PSResource Does Not Properly Evaluate/Compare Available Package Versions Against Specified Version Find-PSResource Does Not Properly Evaluate/Compare Available Package Versions Against Specified Version Jan 24, 2025
@anamnavi anamnavi added Issue-Bug Something isn't working and removed Needs-Triage labels Apr 16, 2025
@anamnavi
Copy link
Member

this most likely needs to be fixed server side so that version comparison is done correctly not lexically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants