0

I currently have nodes set up to pull their configurations from a http pull server (lab environment). The LCMs of these nodes are using configuration names to find their mofs. If I manually modify a mof to be the same name as the configuration name and change the mof data to apply to all computers, they work. What I can not find is an easy way to generate mofs like this from the cmdlets.

Generated mof: servername.mof

@TargetNode='servername'...

Modified mof: configurationname.mof

@TargetNode='*'...

If I try to generate a mof without specifying a node name and having Node * {...} in the configuration script I just get the following error:

out-file : Cannot perform operation because the wildcard path .\configurationname/*.mof did not resolve to a file.

If I create that directory and put exactly one mof in it, the cmdlet will overwrite it and change @TargetNode to a wildcard. Multiple mofs in the directory will result in a different error.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Phil J
  • 11
  • 3

2 Answers2

1

Credit to Alfano Greg on Powershell.org: In the partial configurations I've written, I used the name of the Configuration (in your case "Partial2") as the name of the node. The value of node will determine the name of the .mof file.

Configuration Partial2 {

    Node ('Partial2') {

        File Test {

            Ensure          = "Present"
            DestinationPath = "C:\some\path"
            Type            = "Directory"
        }
    }
}

Ed: The MOF will have 'Partial2' as the TargetNode in the comment header, but the LCM seems to overwrite or ignore this value when it compiles pending.mof so it isn't an issue.

References:
- PowerShell Magazine (2014) - Partial Configurations in Windows Mangement Framework (WMF) 5.0
- Official Partial Configuration documentiation

TravisEz13
  • 2,263
  • 1
  • 20
  • 28
Phil J
  • 11
  • 3
  • Get-DscConfigurationStatus uses comment header from the mof to provide information about mof generation. – N.Gupta May 10 '16 at 17:45
0

If your configuration contains multiple nodes and you want to use the generated mofs as partial configuration, only way to make it work is by renaming the configurationname in mof and changing the file name to match it. However you can divide your configuration such that you have 1 node per configuration. That way you can use same configurationData for all these configurations. You can also file a uservoice request for this issue @ https://windowsserver.uservoice.com/forums/301869-powershell

N.Gupta
  • 326
  • 1
  • 5