To be able to reproduce problem first install duplicate modules of different version:
Install-Module -Name PackageManagement -RequiredVersion "1.3" -Scope CurrentUser
Install-Module -Name PackageManagement -RequiredVersion "1.4.7" -Scope CurrentUser
Now ask Get-Module to get you exact module by specifying fully qualified name of a module
Get-Module -ListAvailable -FullyQualifiedName @{ModuleName = "PackageManagement"; ModuleVersion = "1.3" }
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 1.3 PackageManagement Desk {Find-Package, Get-Package...}
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 1.4.7 PackageManagement Desk {Find-Package, Get-Package...}
Script 1.3 PackageManagement Desk {Find-Package, Get-Package...}
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Basically if we specify FullyQualifiedName with the exact version then that's what the output must be.
However the output includes all the possible modules of different versions (but same name) that one may have on his computer.
Of course if we specify -PSEdition "Core" then there is no output at all.
ModuleVersion specifies the minimum version, the key you want is RequiredVersion.
Thank you, I didn't know that, msdn docs only talk about these 2 and GUID key.
But after your answer I took a look here and it makes sense.