Author Posts

November 11, 2017 at 12:08 pm

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!

November 11, 2017 at 12:13 pm

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!

November 11, 2017 at 12:24 pm

I've duplicated the behaviour using the Pester module

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

will load the correct version

November 11, 2017 at 12:37 pm

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