{"id":1801,"date":"2014-02-25T21:33:00","date_gmt":"2014-02-25T21:33:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2014\/02\/25\/reusing-existing-configuration-scripts-in-powershell-desired-state-configuration\/"},"modified":"2024-02-22T11:24:57","modified_gmt":"2024-02-22T19:24:57","slug":"reusing-existing-configuration-scripts-in-powershell-desired-state-configuration","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/reusing-existing-configuration-scripts-in-powershell-desired-state-configuration\/","title":{"rendered":"Reusing Existing Configuration Scripts in PowerShell Desired State Configuration"},"content":{"rendered":"<div class=\"WordSection1\">\n<p>You are an expert in PowerShell DSC (or maybe not an expert, just someone playing around with configurations in DSC) and have already written fairly large and complex configurations for configuring your environment\/data center. Everything is working well and you are a great fan of DSC. There\u2019s only one problem: your work is <em>complicated<\/em>. Before long, you have a configuration that is hundreds or thousands of lines long \u2013 people from many different teams are editing it. Finding and fixing problems becomes nearly impossible\u2026 your configuration is just too <em>unwieldy<\/em>. Then comes a day when there arises a need to add something more (or maybe delete something) to your configuration. The problem looks trivial to solve right? \u2013Just add one more resource to your (already big) configuration. But you are a forward thinking person and find yourself wondering if there is something clever you can do leverage your existing configuration scripts.<\/p>\n<p class=\"MsoNormal\">That is why we made configurations <strong>composable<\/strong> and <strong>reusable<\/strong><span style=\"font-family: wingdings;\">J<\/span>. Yes, one configuration can call another. How? That is what we are going to cover in this post.<\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">The way to make a configuration reusable is by making it what we call a <strong>composite resource<\/strong>. Let me walk you through an example to do just that.<\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">I have the following parameterized configuration (the parameters of the configuration become the properties of the composite resource) which I will turn into a composite resource:<\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"color: darkblue; font-family: 'Lucida Console'; font-size: 9pt;\">Configuration<\/span><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"> <span style=\"color: blueviolet;\">xVirtualMachine<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkblue;\">param<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">(<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Name of VMs<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">[]]<\/span><span style=\"color: orangered;\">$VMName<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Name of Switch to create<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$SwitchName<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Type of Switch to create<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$SwitchType<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Source Path for VHD<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$VhdParentPath<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Destination path for diff VHD<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$VHDPath<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\">\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Startup Memory for VM<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$VMStartupMemory<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># State of the VM<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">Parameter<\/span>(Mandatory)<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: deepskyblue;\">ValidateNotNullOrEmpty<\/span>()<span style=\"color: darkgray;\">]<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgray;\">[<\/span><span style=\"color: teal;\">String<\/span><span style=\"color: darkgray;\">]<\/span><span style=\"color: orangered;\">$VMState<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">)<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Import the module that defines custom resources<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">Import-DscResource<\/span> <span style=\"color: navy;\">-Module<\/span> <span style=\"color: blueviolet;\">xComputerManagement<\/span><span style=\"color: darkgray;\">,<\/span><span style=\"color: blueviolet;\">xHyper-V<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\">\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Install the HyperV role <\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">WindowsFeature<\/span> <span style=\"color: blueviolet;\">HyperV<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Name<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Hyper-V&#8221;<\/span> <\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\">\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Create the virtual switch <\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">xVMSwitch<\/span> <span style=\"color: orangered;\">$switchName<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Name<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$switchName<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Type<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$SwitchType<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 DependsOn<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;[WindowsFeature]HyperV&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Check for Parent VHD file<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">File<\/span> <span style=\"color: blueviolet;\">ParentVHDFile<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 DestinationPath<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VhdParentPath<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Type<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;File&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 DependsOn<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;[WindowsFeature]HyperV&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Check the destination VHD folder<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">File<\/span> <span style=\"color: blueviolet;\">VHDFolder<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 DestinationPath<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VHDPath<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 Type<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Directory&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 DependsOn<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;[File]ParentVHDFile&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Creae VM specific diff VHD<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkblue;\">foreach<\/span>(<span style=\"color: orangered;\">$Name<\/span> <span style=\"color: darkblue;\">in<\/span> <span style=\"color: orangered;\">$VMName<\/span>)<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 xVHD<\/span> <span style=\"color: darkred;\">&#8220;VhD<\/span><span style=\"color: orangered;\">$Name<\/span><span style=\"color: darkred;\">&#8220;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 {<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$Name<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Path<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VhDPath<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ParentPath<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VhdParentPath<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DependsOn<\/span> <span style=\"color: blueviolet;\">=<\/span> @(<span style=\"color: darkred;\">&#8220;[WindowsFeature]HyperV&#8221;<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkred;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;[File]VHDFolder&#8221;<\/span>)<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkgreen;\"># Create VM using the above VHD<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkblue;\">foreach<\/span>(<span style=\"color: orangered;\">$Name<\/span> <span style=\"color: darkblue;\">in<\/span> <span style=\"color: orangered;\">$VMName<\/span>)<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 xVMHyperV<\/span> <span style=\"color: darkred;\">&#8220;VMachine<\/span><span style=\"color: orangered;\">$Name<\/span><span style=\"color: darkred;\">&#8220;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 {<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ensure<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;Present&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$Name<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VhDPath<\/span> <span style=\"color: blueviolet;\">=<\/span> (<span style=\"color: blue;\">Join-Path<\/span> <span style=\"color: navy;\">-Path<\/span> <span style=\"color: orangered;\">$VhDPath<\/span> <span style=\"color: navy;\">-ChildPath<\/span> <span style=\"color: orangered;\">$Name<\/span>)<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SwitchName<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$SwitchName<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 StartupMemory<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VMStartupMemory<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 State<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$VMState<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MACAddress<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$MACAddress<\/span> <\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WaitForIP<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: orangered;\">$true<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DependsOn<\/span> <span style=\"color: blueviolet;\">=<\/span> @(<span style=\"color: darkred;\">&#8220;[WindowsFeature]HyperV&#8221;<\/span><span style=\"color: darkgray;\">,<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: darkred;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;[xVHD]Vhd<\/span><span style=\"color: orangered;\">$Name<\/span><span style=\"color: darkred;\">&#8220;<\/span>)<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"> } <\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">} <\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">The key is to place the configuration in a file with the extension <strong>schema.psm1<\/strong>. You can take a look <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/12\/05\/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx\">here<\/a> to find out how to deploy a DSC Resource. Here is how it looks on my machine:<\/span><\/p>\n<p><span style=\"font-size: small;\">PS C:\\Program Files\\WindowsPowerShell\\Modules\\TestCompositeResource\\DSCResources\\xVirtualMachine&gt; dir<\/span><\/p>\n<p><span style=\"font-size: small;\">\u00a0\u00a0\u00a0 Directory: C:\\Program Files\\WindowsPowerShell\\Modules\\TestCompositeResource\\DSCResources\\xVirtualMachine<\/span><\/p>\n<p><span style=\"font-size: small;\">Mode\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LastWriteTime\u00a0\u00a0\u00a0\u00a0 Length Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-size: small;\">&#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;&#8212;&#8212;-\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212; &#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-size: small;\">-a&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\/25\/2014\u00a0\u00a0 8:42 PM\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2642 xVirtualMachine.psd1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-size: small;\">-a&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\/25\/2014\u00a0\u00a0 8:42 PM\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2957 xVirtualMachine.schema.psm1\u00a0\u00a0\u00a0<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\"><em>Note: Take note of the .psd1 file (xVirtualMachine.psd1) inside the DSCResources folder. On my first attempt, I did not put that file in there and wasted some time trying to figure out where I was going wrong (yes, yes, yes a valid PowerShell module must have one out of .psd1, .psm1, .cdxml, .dll extension and it took me some time to figure out the fact that .schema.psm1 does not satisfy that condition).<\/em><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Inside the .psd1 file, I have this line:<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: small;\">RootModule <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8216;xVirtualMachine.schema.psm1&#8217; <\/span><\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">That is it, you are done!<\/span><\/p>\n<p class=\"MsoNormal\"><em>Edit: For the resource to be discoverable and usable, it must be part of a valid PowerShell module.\u00a0 For this example to work, you would also need to create a TestCompositeResource.psd1 module manifest under the &#8220;TestCompositeResource&#8221; Folder.\u00a0 The best way to do that is by running &#8220;New-ModuleManifest -path <span style=\"font-size: small;\">&#8220;C:\\Program Files\\WindowsPowerShell\\Modules\\TestCompositeResource\\TestCompositeResource.psd1&#8243;&#8221;.\u00a0 Sorry for the confusion!<\/span>\n<\/em><\/p>\n<p class=\"MsoNormal\"><em>\u00a0<\/em><\/p>\n<p class=\"MsoNormal\">\n<p><span style=\"font-size: small;\">PS C:\\&gt; Get-DscResource -Name xVirtualMachine<\/span><\/p>\n<p><span style=\"font-size: small;\">ImplementedAs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Module\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Properties\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-size: small;\">&#8212;&#8212;&#8212;&#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;&#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-size: small;\">Composite\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 xVirtualMachine\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TestCompositeResource\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {VMName, SwitchName, SwitchType, VhdParentPath&#8230;}<\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Your configuration shows up as a <strong>composite resource<\/strong>.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Let us now see how to use it:<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"color: darkblue; font-family: 'Lucida Console'; font-size: 9pt;\">configuration<\/span><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"> <span style=\"color: blueviolet;\">RenameVM<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">Import-DscResource<\/span> <span style=\"color: navy;\">-Module<\/span> <span style=\"color: blueviolet;\">TestCompositeResource<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0<\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"> Node <span style=\"color: blueviolet;\">localhost<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">{<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 xVirtualMachine <span style=\"color: blueviolet;\">VM<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 {<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VMName <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;Test&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SwitchName <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;Internal&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SwitchType <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;Internal&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VhdParentPath <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;C:\\Demo\\Vhd\\RTM.vhd&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VHDPath <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;C:\\Demo\\Vhd&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VMStartupMemory <span style=\"color: darkgray;\">=<\/span> <span style=\"color: purple;\">1024MB<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VMState <span style=\"color: darkgray;\">=<\/span> <span style=\"color: darkred;\">&#8220;Running&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0 <\/span><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">Node <span style=\"color: darkred;\">&#8220;192.168.10.1&#8221;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0 {<\/span><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0 <\/span><\/span><\/p>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0 xComputer<\/span> <span style=\"color: blueviolet;\">Name<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 {<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Name<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;SQL01&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\"><span style=\"color: blue;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DomainName<\/span> <span style=\"color: blueviolet;\">=<\/span> <span style=\"color: darkred;\">&#8220;fourthcoffee.com&#8221;<\/span> <\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">}<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\"><span style=\"font-family: 'Lucida Console'; font-size: 9pt;\">} <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white; line-height: normal; margin-bottom: 0pt;\">\n<p class=\"MsoCommentText\"><span style=\"font-size: small;\">We have used the dynamic keyword Import-DscResource to make our composite resource type available in the configuration. The parameters of the composite resource become its properties. You can discover this in two ways, one way is to use the Get-DscResource cmdlet as above and the other is in ISE. I like the one in ISE since it does not require me to shift my focus to the command window and type in the cmdlet. You can take the cursor to the place where you have the name of the resource, and press <strong>CTRL+space. <\/strong> You can discover all the resources by using CTRL+Space after the configuration keyword as well. .You have to do it after Import-DscResource if importing custom resources.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Here is what ISE displays:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/02\/0458.Untitled_thumb_07690A9E.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20322\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/02\/0458.Untitled_thumb_07690A9E.png\" alt=\"Image 0458 Untitled thumb 07690A9E\" width=\"244\" height=\"121\" \/><\/a><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Tab completion works on the names of the properties just like any other resource, isn\u2019t that cool?<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">This way, I have a configuration, where I reused one of my existing configurations and added one more resource to the overall configuration of my machine. This configuration first creates a VM and then uses the xComputerResource to rename it. I can thus build upon my existing configurations as and when the need arises for more complex configurations.<\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Happy configuring!<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Abhik Chatterjee<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: small;\">Windows PowerShell Developer<\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\">\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>You are an expert in PowerShell DSC (or maybe not an expert, just someone playing around with configurations in DSC) and have already written fairly large and complex configurations for configuring your environment\/data center. Everything is working well and you are a great fan of DSC. There\u2019s only one problem: your work is complicated. Before [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[142,150,251,345,348],"class_list":["post-1801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-desired-state-configuration","tag-dsc","tag-powershell-4-0","tag-windows-powershell-4-0","tag-windows-powershell-desired-state-configuration"],"acf":[],"blog_post_summary":"<p>You are an expert in PowerShell DSC (or maybe not an expert, just someone playing around with configurations in DSC) and have already written fairly large and complex configurations for configuring your environment\/data center. Everything is working well and you are a great fan of DSC. There\u2019s only one problem: your work is complicated. Before [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=1801"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=1801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}