Please feel free to provide feedback or file bugs here.

[BUG] Cannot import both PSDesiredStateConfiguration in-box module and PSDscResources (gallery module) in the same configuration

OS: Windows Server 2016 1607 (14393.1593)
PSVersionTable:
Name Value
---- -----
PSVersion 5.1.14393.1532
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1532
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

PSDscResource module: v2.8.0.0

Take a look at this configuration:
Configuration DependentConfig
{
Import-DscResource -ModuleName PSDscResources -Name Registry

Node MyNode01
{

File SetupScript
{
DestinationPath = 'C:\Scripts\hello.txt'
Contents = 'somecommand'
Type = 'File'
Ensure = 'Present'
DependsOn = '[Registry]regCheck'
}

Registry regCheck
{
Key = 'HKEY_LOCAL_MACHINE\SYSTEM\SomeKey'
ValueName = 'SomeValue'
ValueData = 0
ValueType = 'DWord'
Ensure = 'Present'
}
}
}

DependentConfig -OutputPath C:\DependentConfig

This requires PSDscResources module version 2.8.0.0 from the gallery and the file resource from the PSDesiredStateConfiguration in-box module. However, compiling this configuration will fail with a message that File resource cannot be loaded. If we remove -Name File from the first import command, you will see an error that Registry resource cannot be found. We have to use -Name with PSDscResources since PSDesiredStateConfiguration already exports the same resource.

So, the only work around at this time is to remove the PSDesiredStateConfiguration import completely from the configuration so that we can at least compile this. Here is something that works.

Configuration DependentConfig
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName PSDscResources -Name Registry

Node MyNode01
{

File SetupScript
{
DestinationPath = 'C:\Scripts\hello.txt'
Contents = 'somecommand'
Type = 'File'
Ensure = 'Present'
DependsOn = '[Registry]regCheck'
}

Registry regCheck
{
Key = 'HKEY_LOCAL_MACHINE\SYSTEM\SomeKey'
ValueName = 'SomeValue'
ValueData = 0
ValueType = 'DWord'
Ensure = 'Present'
}
}
}

DependentConfig -OutputPath C:\DependentConfig

4 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Ravikanth Chaganti shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Indhu Sivaramakrishnan commented  ·   ·  Flag as inappropriate

        Hello Ravikanth,
        This is a bug on our language side. Even though the configuration succeeds without importing PSDesiredStateConfiguration explicitly, the warning message is confusing. I have filed an internal bug on our end and we will triage this appropriately. Please let me know if you have any questions.
        -Indhu

      • Ravikanth Chaganti commented  ·   ·  Flag as inappropriate

        Yes! I have the most up to date OS image and I still see the issue when I try to import both PSDesiredStateConfiguration and PSDscResources modules.

        PS C:\Scripts> $PSVersionTable

        Name Value
        ---- -----
        PSVersion 5.1.14393.1532
        PSEdition Desktop
        PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
        BuildVersion 10.0.14393.1532
        CLRVersion 4.0.30319.42000
        WSManStackVersion 3.0
        PSRemotingProtocolVersion 2.3
        SerializationVersion 1.1.0.1

      • Ravikanth Chaganti commented  ·   ·  Flag as inappropriate

        Not sure if I can update the original posting but the configuration that works should not have Import-DscResource -ModuleName PSDesiredStateConfiguration line.

      Feedback and Knowledge Base