no mof generated with composite resource

This topic contains 4 replies, has 4 voices, and was last updated by  Simon Steur 3 years, 2 months ago.

  • Author
    Posts
  • #18870

    Simon Steur
    Participant

    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
  • #18872

    David Jones
    Participant

    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
  • #18894

    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
        {
    
    
  • #18897

    David Jones
    Participant

    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.

  • #18910

    Simon Steur
    Participant

    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!

You must be logged in to reply to this topic.