Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Find-Module does not allow parameters MinimumVersion and AllVersions to be specified together #676

Description

@tristanbarcelon

If I'm synchronizing PSGallery packages to a private Azure Devops feed, I would like to be able to copy versions of PSGallery modules newer than the latest version stored in private Azure Devops feed. Hence, we are specifying a MinimumVersion to Find-Module in order to limit results. Unfortunately, specifying MinimumVersion will only return the latest version, rather than all versions greater than or equal to MinimumVersion. I would prefer avoiding AllVersions parameter because some modules such as dbatools have a lot of versions to sort over.

Steps to reproduce

Find-Module -Name 'aws.tools.common' -MinimumVersion '4.1.36' -Repository PSGallery -AllVersions

Expected behavior

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
4.1.38               AWS.Tools.Common                    PSGallery            The AWS Tools for PowerShell lets develop...
4.1.37               AWS.Tools.Common                    PSGallery            The AWS Tools for PowerShell lets develop...
4.1.36               AWS.Tools.Common                    PSGallery            The AWS Tools for PowerShell lets develop...

Actual behavior

Find-Module: You cannot use the parameter AllVersions with RequiredVersion, MinimumVersion or MaximumVersion in the same command.

Environment data

on Windows

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

on Ubuntu Linux
Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Linux 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> Get-Module -ListAvailable PowerShellGet,PackageManagement

on Windows
    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…

on Ubuntu Linux
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…
> Get-PackageProvider -ListAvailable

on Windows
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.5.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
PowerShellGet            1.0.0.1

on Ubuntu Linux
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.5.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…

Activity

  1. StevenBucher98 commented on Mar 10, 2022

    @StevenBucher98
    Collaborator

    You can get this behavior in PowerShellGetv3, and example of this is:
    Find-PSResource -Name aws.tools.common -Version [4.1.36, ]
    Another way to get this with the current v2 behavior is:
    Find-Module -Name aws.tools.common -AllVersions | where {$_.Version -ge "4.1.36"}

  2. tristanbarcelon commented on Mar 18, 2022

    @tristanbarcelon
    Author

    You can get this behavior in PowerShellGetv3, and example of this is: Find-PSResource -Name aws.tools.common -Version [4.1.36, ] Another way to get this with the current v2 behavior is: Find-Module -Name aws.tools.common -AllVersions | where {$_.Version -ge "4.1.36"}

    Nice syntax on V3 and this would work pretty well with the list of modules I'm synchronizing which looks like this:

    [HashTable] $ModulesToSync = @{
    'AzurePipelinesPS' = '(3.0.13,4.0]'
    'Carbon' = '(2.9.2,2.11]'
    'dbatools' = '[1.0.101,1.2]'
    'MSI' = '3.3'
    'NameIT' = '(2.1.1,2.3]'
    'powershell-yaml' = '(0.4.1,0.4.2]'
    'PSOneTools' = '[1.0,2.4]'
    'RabbitMQTools' = '[1.0,1.5]'
    'SqlServer' = '[21.0.17099,21.1.18256]'
    'VcRedist' = '(2.0.181,3.0]'
    'VenafiTppPS' = '(1.2.3,2.2.7]'
    'ImportExcel' = '[6.5,7.5]'
    'VSSetup' = '[1.0,2.2]'
    'PSRabbitMQ' = '[0.3.1,0.3.5]'
    'VSTeam' = '[6.4.6,7.7]'
    'TFSCmdlets' = '2.0'
    'Az.Accounts' = '2.5.1'
    'Az.KeyVault' = '3.4.5'
    'Az.ApplicationInsights' = '1.2.0'
    'Az.Resources' = '[4.2,5.4]'
    'AWS.Tools.SecurityToken' = '4.1.16'
    'AWS.Tools.Common' = '4.1.16'
    'AWS.Tools.EC2' = '4.1.16'
    'AWS.Tools.ECR' = '4.1.16'
    'AWS.Tools.EKS' = '4.1.16'
    'AWS.Tools.Route53' = '4.1.16'
    'AWS.Tools.S3' = '4.1.16'
    'AWS.Tools.Elasticache' = '4.1.16'
    'AWS.Tools.SimpleSystemsManagement' = '4.1.16'
    'AWS.Tools.RDS' = '4.1.16'
    'AWS.Tools.Pricing' = '4.1.16'
    'AWS.Tools.EBS' = '4.1.16'
    'Join-Object' = '2.0.2'
    'MicrosoftTeams' = '[2.0.0,4.1]'
    'NtObjectManager' = '[1.0,1.2]'
    'Bicep' = '[1.0.0,2.1]'
    'VenafiPS' = '[3.0,4.2]'
    'MarkdownToHtml' = '1.0'
    'ComputerManagementDsc' = '[8.0,8.5]'
    'SqlServerDsc' = '[13.0,15.2]'
    'ServiceNow' = '[1.8,3.1]'
    }

    I based the versioning structure upon my understanding of nuget versioning range https://docs.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges. Unfortunately, when using Find-PSResource on v3 with any module that has a single version, its behavior is different from one specified in nuget versioning range. I had to convert '4.1.16' to '[4.1.16,]' for it to behave like >=. Steven Bucher (@StevenBucher98), is that the intended behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions