Skip to content

Unable to run a configuration that imports MultiClassNestedModulesSameDir #1

Description

@StephenTung-CR

Thanks for posting the answer on stackoverflow about using multiple class based dsc resources with only one module .

I'd like to incorporate this to my project but have no luck when I imported it to my configuration. Have you tried it and got it to work before?

This is what I did to test it:

  1. I copied your directory to C:\windows\program files\windowspowershell\modules

image

  1. I created a configuration
configuration test 
{
    Import-DscResource -ModuleName MultiClassesNestedModulesSameDir

    node localhost {
        LocalConfigurationManager
        {
            RefreshMode = "Push"
            DebugMode = "All"
        }

        NestedA nested {
            path = "C:\temp\"
        }
    }
}

test -verbose

Start-DscConfiguration test -wait -force -verbose
  1. Ran the configuration and got this error: Failed to create an object of PowerShell class NestedA
PS C:\git\powershell-sandbox> .\configurationWithMultipleDscResourceInOneModule.ps1


    Directory: C:\git\powershell-sandbox\test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2016-05-27  10:02 AM           1884 localhost.mof
-a----       2016-05-27  10:02 AM           1024 localhost.meta.mof
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'methodName' =
SendConfigurationApply'.
VERBOSE: An LCM method call arrived from computer STUNG-PC with user sid S-1-5-21-2636790278-1621244947-15913188-1001.
VERBOSE: [STUNG-PC]: LCM:  [ Start  Set      ]
VERBOSE: [STUNG-PC]:                            [DSCEngine] Importing the module C:\Program
Files\WindowsPowerShell\Modules\MultiClassesNestedModulesSameDir\MultiClassesNestedModulesSameDir.psd1 in force mode.
VERBOSE: [STUNG-PC]: LCM:  [ Start  Resource ]  [[NestedA]nested]
VERBOSE: [STUNG-PC]: LCM:  [ Start  Test     ]  [[NestedA]nested]
VERBOSE: [STUNG-PC]:                            [[NestedA]nested] Importing the module MultiClassesNestedModulesSameDir in
force mode.
VERBOSE: [STUNG-PC]: LCM:  [ End    Test     ]  [[NestedA]nested]  in 0.4160 seconds.
Failed to create an object of PowerShell class NestedA.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : InstantiatePSClassObjectFailed
    + PSComputerName        : localhost

VERBOSE: [STUNG-PC]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 1.219 seconds

Any clue what might be wrong with what I'm doing?

I'm on Powershell 5.0.10586.122.

Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions