Import-Module -FullyQualifiedName not working as expected?

Welcome Forums General PowerShell Q&A Import-Module -FullyQualifiedName not working as expected?

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #83972

    Participant
    Points: 53
    Team Member
    Rank: Member

    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

    Participant
    Points: 53
    Team Member
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    I've duplicated the behaviour using the Pester module

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

    will load the correct version

  • #83978

    Participant
    Points: 53
    Team Member
    Rank: Member

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

The topic ‘Import-Module -FullyQualifiedName not working as expected?’ is closed to new replies.