Import-DscResource -ModuleVersion not obey

moduleVersion does not seems to be doing anything (WMF 5)

code
ensure two versions of the same module is installed

  Install-Module xWebAdministration -Version 1.13.0.0
  Install-Module xWebAdministration -RequiredVersion 1.11.0.0

run this basic dsc config

Configuration TestDSCVersion {
    
   Import-DscResource  -ModuleName  xWebAdministration -ModuleVersion 1.11.0.0

    node ("localhost")
    {

        xWebAppPool ScooplaApplicationPool
        {
            Ensure = 'Absent'
            Name =   "asdfasdf"
        }

    }
  }


TestDSCVersion

the output of the mof file is:


instance of MSFT_xWebAppPool as $MSFT_xWebAppPool1ref
{
ResourceID = "[xWebAppPool]ScooplaApplicationPool";
 Ensure = "Absent";
 SourceInfo = "C:\\Dev\\Scoopla.Dev\\ModuleVersion.ps1::14::5::xWebAppPool";
 Name = "asdfasdf";
 ModuleName = "xWebAdministration";
 ModuleVersion = "1.13.0.0";

 ConfigurationName = "TestDSCVersion";

};

ModuleVersion = “1.13.0.0”; instead of ModuleVersion = “1.11.0.0”

Can you run Get-Module and see both versions are indeed showing ?
Also, can you show the exact version of ps you have?

Major Minor Build Revision


5 0 10586 117

Yes both versions are definitely installed.

ModuleType Version Name ExportedCommands


Manifest 1.13.0.0 xWebAdministration
Manifest 1.11.0.0 xWebAdministration

I will check on 5.0 version of Powershell soon. However on 5.1 I get the expected result with ModuleVersion = 1.11.0.0 in localhost.mof file.

Yes I see that issue on PS version 5.0. However, the following syntax works:

Import-DscResource  -ModuleName  @{moduleName="xWebAdministration";requiredversion="1.11.0.0"}

thank Nitin, using the powershell module syntax works