Importing multiple versions of modules (this is PS7):
Import-Module -Name MyModule -RequiredVersion 1.0.28
Import-Module -Name MyModule -RequiredVersion 1.0.29
Will load both versions into your session:
Get-Module -Name MyModule
Outputs:
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 1.0.28 MyModule
Script 1.0.29 MyModule
This becomes quite confusing when you're trying to write CI/CD scripts, because someone may have multiple versions loaded locally. In my case I want to ensure a specific version is loaded before continuing.
Which version does PS actually use in this scenario? Is it the last loaded rather than the highest version?
Is there an easy way to ensure a specific version is being used, short of looping over all other versions and removing them?