dsc

Is it possible to have common configuration in DSC configuration block?


I'm wondering if it's possible in configuration block which contains 2 nodes to have also configuration which will be common between 2 nodes without duplicating code (some sort of include configuration) Something like below

Configuration {
   Node One {
      ...
      $commonResources
   }
   Node Two
   {
      ...
      $commonResources
   }

   $commonResouces = 
   {
   File CommonFile
   {
      
   }
   }
}

Solution

  • Configuration {
       Node $AllNodes.NodeName {
          $commonResources
          File CommonFile
          {
          
          }
       }
       Node One {
          ...
       }
       Node Two
       {
          ...
       }
    }
    

    All common configurations can be placed under the $AllNodes.NodeName node. All configurations under this node will be on all nodes. I hope this answers your question.