psd1 manifest - RequiredModules inefficient?

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 4 months, 1 week ago.

  • Author
    Posts
  • #46973
    Profile photo of Steve Ayers
    Steve Ayers
    Participant

    I have created a module (one cmdlet) for my colleagues to easily process Migrations from Azure Classic to Resource Manager:
    https://www.powershellgallery.com/packages/MigrateTo-AzureRM/1.2.0.2/

    This cmdlet is dependent on the installation of AzureRM & Azure PSGallery modules. In scripts which depend on modules, I would check for modules like so:

    "Azure","AzureRM" | % {
        if (!(Get-Module $_))
        {
            "Installing $_ module" ; Install-Module -Name $_ -Repository PSGallery
        }
    }
    

    However, I thought I'd use a manifest, which you can find a copy of here:
    https://www.powershellgallery.com/packages/MigrateTo-AzureRM/1.2.0.2/Content/MigrateTo-AzureRM.psd1

    When creating the input for RequiredModules, I found that you had to specify either 'RequiredVersion' or 'ModuleVersion'.

    Now, every time I install-module, it will attempt to download the dependency modules, and when it does, it takes quite a while due to the sub-modules linked to the AzureRM & Azure modules.

    I'd ideally like to specify that you can use any version of the AzureRM & Azure modules, or any version above, for example, 1.5.0. Otherwise, as the Azure modules are updated, and they are updated on my colleagues' machines, the module will download a legacy version of the Azure & AzureRM modules.

    I may be making a mistake with how I'm writing my manifest file, so any advice is much appreciated!

    • This topic was modified 4 months, 3 weeks ago by Profile photo of Steve Ayers Steve Ayers. Reason: Formatting changes
    • This topic was modified 4 months, 3 weeks ago by Profile photo of Steve Ayers Steve Ayers. Reason: Addnig line about ModuleVersion and RequiredVersion
  • #48269
    Profile photo of Don Jones
    Don Jones
    Keymaster

    If I'm understanding that you're doing and what you're asking, then "no." Right now, the versioning doesn't understand anything but exact numbers – there's no "minimum level" or anything. I can see where that'd be useful, and you might consider suggesting it in PowerShell's UserVoice. Or possibly instead look into scripting Update-Module, which has some "grab the latest version or don't do anything" intelligence.

You must be logged in to reply to this topic.