nitinbps / DSCResources

1 stars 0 forks source link

Unable to run a configuration that imports MultiClassNestedModulesSameDir #1

Open StephenTung-CR opened 8 years ago

StephenTung-CR commented 8 years ago

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

2) 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

3) 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.

larssb commented 6 years ago

Looks like he found out that it is not working. See > Issue on StackOverFlow

@nitinbps please invalidate the code in this repo. so that people do not try it out 👍 thank you.

nitinbps commented 6 years ago

@larssb can you please post the correct stackoverflow link, the one you posted links to github

larssb commented 6 years ago

@nitinbps sorry my mistake. Consider it done :-)