Author Posts

September 17, 2014 at 5:42 am

Hi all,

I'm having an issue where the .mof file doesn't get generated when using a composite resource in it.The directory gets created fine and no errors are shown. It might be a simple issue to some fresh eyes, but I'm not seeing it đŸ™‚

The composite resource gets recognized fine and as I said, no errors are shown. I'd appreciate any help!

Here are my configuration files:

[b]composite resource[/b]

Configuration OfficeServer
{
    PARAM
    (
        [string]$IPAddress

    )
    
    Import-DscResource -Modulename XNetworking, PSDesiredStateConfiguration
 
    {
        
        xIPAddress IPAddress 
        {
            IPAddress = $IPAddress
            InterfaceAlias = "Ethernet"
            DefaultGateway = "192.168.10.1"
            SubnetMask = 24
            AddressFamily = "IPV4"
        }

        xDNSServerAddress DNSServer 
        {
            Address = "192.168.10.44"
            InterfaceAlias = "Ethernet"
            AddressFamily = "IPV4"
        }

    }

}

[b]the configuration to generate the .mof[/b]

Configuration test
{

    Import-DscResource -modulename CommonConfig 

    Node localhost
    {
        OfficeServer test
        {
            IPAddress = "192.168.10.92"
        }
 
    }


}

test

September 17, 2014 at 6:33 am

http://blogs.msdn.com/b/powershell/archive/2014/04/25/understanding-import-dscresource-keyword-in-desired-state-configuration.aspx

Import-DscResource does not support multiple modules.

change it to

Import-DscResource -Modulename XNetworking
Import-DscResource -Modulename PSDesiredStateConfiguration

September 17, 2014 at 12:16 pm

I belive that multiple modules is supported, quote from the linked article above:

ModuleName is the name of the module that contains the resources to be imported. This parameter can contain either string array of module names or modules specification object. e.g.

Import-DSCResource –ModuleName xActiveDirectory, xSmbShare

Just from looking at your code and without testing anything, my longshot is:

Try to move the import of resources/modules out of the composite resource and put everything in you configuration.

Configuration OfficeServer
{
    PARAM
    (
        [string]$IPAddress
    )
        xIPAddress IPAddress 
        {

Configuration test
{
    Import-DscResource -modulename CommonConfig,Networking, PSDesiredStateConfiguration
    Node localhost
    {

September 17, 2014 at 1:45 pm

My mistake. I had misread the part on Multiple ModuleName and multiple Name in the same command.

I have placed the appropriate Import-DscResorce commands in both for mine.

the only reason for having it in Configuration OfficeServer is that intellisense will not work right without it.

September 18, 2014 at 12:49 am

First of all thanks for the replies!

The answers you gave me made me move things around in the composite resource again and that's when I noticed I had a pair of curly brackets too much in it. *sigh*
After removing those it worked fine, also with the import-dscresource in the composite resource itself.

[b]updated version that works[/b]

Configuration OfficeServer
{
    PARAM
    (
        [string]$IPAddress
    )

    Import-DscResource -modulename XNetworking, PSDesiredStateConfiguration
 
        xIPAddress IPAddress 
        {
            IPAddress = $IPAddress
            InterfaceAlias = "Ethernet"
            DefaultGateway = "192.168.10.1"
            SubnetMask = 24
            AddressFamily = "IPV4"
        }

        xDNSServerAddress DNSServer 
        {
            Address = "192.168.10.44"
            InterfaceAlias = "Ethernet"
            AddressFamily = "IPV4"
        }
}

[b]configuration to generate the .mof[/b}

Configuration test
{
 
    Import-DscResource -modulename CommonConfig 
 
    Node localhost
    {
        OfficeServer test
        {
            IPAddress = "192.168.10.92"
        }
 
    }
 
 
}
 
test

Again, thanks for the fresh look!