Import-Module -FullyQualifiedName not working as expected?

This topic contains 3 replies, has 2 voices, and was last updated by  Missy Januszko 6 months, 1 week ago.

  • Author
  • #83972

    Missy Januszko

    I have two versions of PSScriptAnalyzer in C:\Program Files\WindowsPowerShell\Modules – version 1.13.0 and 1.16.0.
    If I use

    import-module -requiredversion 1.13.0

    and then do get-command -module PSScriptAnalyzer I see that 1.13.0 is loaded. However, if I remove the module and repeat the import using -FullyQualifiedName

    import-module -FullyQualifiedName @{ModuleName = 'PSScriptAnalyzer';ModuleVersion = '1.13.0'}

    and repeat the get-command -module PSScriptAnalyzer, I see the commands from 1.16.0 instead. Any ideas? PEBKAC error, or bug? (I've already done internet searches and can't find any reported bugs.) TIA!

  • #83974

    Missy Januszko

    I did notice that instead of using -ModuleVersion, I can use -RequiredVersion and get the expected results. Still would like to know why -ModuleVersion doesn't work though!

  • #83977

    Richard Siddaway

    I've duplicated the behaviour using the Pester module

    Import-Module -FullyQualifiedName @{Modulename = 'Pester'; RequiredVersion = '4.0.2'}

    will load the correct version

  • #83978

    Missy Januszko

    Suddenly this explains a lot of "unexpected" behavior in some of my DSC configs as well where we're using -ModuleVersion.

You must be logged in to reply to this topic.