{"id":1661,"date":"2014-05-29T16:38:00","date_gmt":"2014-05-29T16:38:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2014\/05\/29\/wish-i-can-author-dsc-resource-in-c\/"},"modified":"2019-02-18T13:05:18","modified_gmt":"2019-02-18T20:05:18","slug":"wish-i-can-author-dsc-resource-in-c","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/wish-i-can-author-dsc-resource-in-c\/","title":{"rendered":"Wish I can author DSC Resource in C#!!"},"content":{"rendered":"<p class=\"MsoCommentText\"><span style=\"font-size: 11pt\">In previous <\/span><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/11\/15\/hungry-for-more-windows-powershell-desired-state-configuration-resources.aspx\"><span style=\"font-size: 11pt\">blog<\/span><\/a><span style=\"font-size: 11pt\">, we learned how one can use their PowerShell skills to author DSC resources very easily. Still there are folks (we met some at TechEd NA) who want to author their DSC resources using C# because they are more productive with it than PowerShell language. Well, <\/span>you can fully leverage the power of DSC by writing your resources in C#. In this blog, we will explore how you can write a C# based DSC resource and later seamlessly consume it from your DSC Configurations.<\/p>\n<h2 class=\"WordSection1\"><span style=\"color: #004080\">Authoring DSC resources in C#<\/span><\/h2>\n<p class=\"MsoNormal\">For the purpose of this blog, we will write a DSC resource named &ldquo;<strong>xDemoFile<\/strong>&rdquo;. This resource will be used to assert the existence of a file and its contents. It is similar to a <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dn282129.aspx\">File<\/a> resource but with limited functionalities.<\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"text-indent: -0.5in;margin-left: 38.65pt\"><span style=\"color: #0080c0\"><strong><span style=\"color: #1f4d78;line-height: 107%;font-family: 'Calibri Light','sans-serif';font-size: 12pt\">I)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/strong><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">Project Setup<\/span><\/strong><\/span>:-<\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-indent: -0.25in;margin-left: 1in\">a)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Open visual studio<\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-indent: -0.25in;margin-left: 1in\">b)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Create a C# project and provide the name (such as&nbsp; &ldquo;cSharpDSCResourceExample&rdquo;)<\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-indent: -0.25in;margin-left: 1in\">c)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span> Select &ldquo;Class Library&rdquo; from the available project templates<\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"text-indent: -0.25in;margin-left: 1in\">d)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Hit &ldquo;Ok&rdquo;<\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"text-indent: -0.25in;margin-left: 1in\">e)&nbsp;&nbsp;&nbsp; Add assembly reference to system.automation.management.dll preferably from PowerShell SDK [but you can add assembly reference to your project from the windows assembly cache, GAC <span style=\"line-height: 107%;font-size: 8pt\">(<span style=\"color: black\">&lt;systemDrive&gt;\\ Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\System.Management.Automation\\v4.0_3.0.0.0__31bf3856ad364e35\\System.Management.Automation.dll<\/span>)]<\/span>.<\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"text-indent: -0.25in;margin-left: 1in\">f)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>*<strong>Update the assembly name to match the DSC resource name<\/strong>. (write right click on the project then hit properties and change the Assembly Name to <strong>MSFT<\/strong>_<strong>xDemoFile)<\/strong><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin-left: 1in\"><strong>&nbsp;<\/strong><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"text-indent: -0.5in;margin-left: 38.65pt\"><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">II)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/strong><\/span><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\"><span style=\"color: #0080c0\">Resource Definition<\/span> <\/span><\/strong><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\">Similar to script based DSC resource. You will need to define the input and output parameters of your resources in &lt;ResourceName&gt;.schema.mof.&nbsp; You can generate the schema of your resource using the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/11\/19\/resource-designer-tool-a-walkthrough-writing-a-dsc-resource.aspx\">Resource Designer Tool<\/a>.<\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\">Save the following in to a file named MSFT_xDemoFile.Schema.mof<strong> <\/strong><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">[ClassVersion(&#8220;1.0.0&#8221;), FriendlyName(&#8220;xDemoFile&#8221;)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">class MSFT_XDemoFile : OMI_BaseResource<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">{<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Key, Description(&#8220;path&#8221;)] String Path;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Write, Description(&#8220;Should the file be present&#8221;), ValueMap{&#8220;Present&#8221;,&#8221;Absent&#8221;}, Values{&#8220;Present&#8221;,&#8221;Absent&#8221;}] String Ensure;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Write, Description(&#8220;Contentof file.&#8221;)] String Content;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 10pt\">};<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"color: #1f497d\">&nbsp;<\/span><\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"margin-left: 0.75in\"><span class=\"Heading3Char\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"text-indent: -0.5in;margin-left: 38.65pt\"><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">III)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/strong><\/span><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\"><span style=\"color: #0080c0\">Resource Implementation<\/span> <\/span><\/strong><\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.25in\">In order to write DSC Resources in C#, you need to implement three PowerShell cmdlets. PowerShell cmdlets are written by inheriting from <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.management.automation.pscmdlet(v=vs.85).aspx\">PSCmdlet<\/a> or <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.management.automation.cmdlet(v=vs.85).aspx\">Cmdlet<\/a>. Detail on how to write PowerShell Cmdlet in C# can be found in <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd901838(v=vs.85).aspx\">this<\/a> MSDN documentation.<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.25in\">See below for the signature of the cmdlets:-<\/p>\n<p class=\"MsoSubtitle\" style=\"text-indent: 0.25in\"><strong>Get-TargetResource<\/strong><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">OutputType<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">typeof<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(System.Collections.<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Hashtable<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">))]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Cmdlet<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">VerbsCommon<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.Get, <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;TargetResource&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">class <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">GetTargetResource<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> : <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">PSCmdlet<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">true<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Path { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: 0.5in;padding-left: 30px\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;summary&gt;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 30px\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\"> Implement the logic to write the current state of the resource as a <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 30px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\"><span style=\"background-color: #ffffff\">\/\/\/<\/span> Hash table with keys being the resource properties <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 30px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\">\/\/\/ and the Values are the corresponding current values on the target machine.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 30px\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 30px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;\/summary&gt;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">protected <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">override <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">void<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> ProcessRecord()<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"background: white;color: black;line-height: 107%;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"padding-left: 120px\"><span style=\"background: white;color: black;line-height: 107%;font-family: consolas;font-size: 9.5pt\">\/\/ Download the zip file at the end of this blog to see sample implementation.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"padding-left: 90px\"><span style=\"background: white;color: black;line-height: 107%;font-family: consolas;font-size: 9.5pt\">&nbsp;}<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoSubtitle\" style=\"text-indent: 0.25in\"><strong>Set-TargetResouce<\/strong><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">[<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">OutputType<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">typeof<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">void<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">))]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Cmdlet<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">VerbsCommon<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.Set, <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;TargetResource&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">class <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">SetTargetResource<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> : <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">PSCmdlet<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">private<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> _ensure;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">private<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> _content;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">true<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Path { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">false<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">ValidateSet<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Present&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Absent&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, IgnoreCase = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">true<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Ensure {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\">\/\/ set the default to present.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">return<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> (<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._ensure ?? <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Present&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._ensure = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">value<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Content {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">return<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> (<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.IsNullOrEmpty(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content) ? <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> : <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content); }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">value<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\"> \/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;summary&gt;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\"> Implement the logic to set the state of the machine to the desired state.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;\/summary&gt;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">protected <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">override <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">void<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> ProcessRecord()<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 0.5in;text-align: left;line-height: normal;text-indent: 0.5in;padding-left: 30px\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">\/\/Implement the set method of the resource <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: 0.5in;padding-left: 60px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 8pt\">\/* Uncomment this section if your resource needs a machine reboot.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 1in;line-height: normal;padding-left: 60px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 8pt\">PSVariable DscMachineStatus = new PSVariable(&#8220;DSCMachineStatus&#8221;, 1, ScopedItemOptions.AllScope);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;padding-left: 60px;margin-bottom: 0pt\"><span style=\"background: white;color: green;font-family: consolas;font-size: 8pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.SessionState.PSVariable.Set(DscMachineStatus);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: 0.5in;padding-left: 60px\"><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\">*\/<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"color: black;line-height: 107%;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoSubtitle\" style=\"text-indent: 0.25in\"><strong>Test-TargetResource&nbsp;<\/strong>&nbsp;&nbsp;&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"color: #2e74b5;font-family: 'Calibri Light','sans-serif';font-size: 13pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">[<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Cmdlet<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Test&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;TargetResource&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">OutputType<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">typeof<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Boolean<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">))]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">class&nbsp;<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">TestTargetResource<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> : <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">PSCmdlet<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">private&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> _ensure;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">private&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> _content;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">true<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Path { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">false<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">ValidateSet<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Present&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Absent&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, IgnoreCase = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">true<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Ensure<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\">\/\/ set the default to present.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">return<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> (<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._ensure ?? <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;Present&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._ensure = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">value<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">Parameter<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(Mandatory = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">false<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">)]<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">public&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> Content<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">get<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">return<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> (<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">string<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.IsNullOrEmpty(<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content) ? <\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;&ldquo;:<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content);}<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">set<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> { <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">._content = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">value<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 6pt;line-height: normal;text-indent: 0.5in\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;summary&gt;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 42pt;line-height: normal\"><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\"> Write a Boolean value which indicates whether the current machine is in&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt 42pt;line-height: normal\"><span style=\"background: white;color: green;font-family: consolas;font-size: 9.5pt\">\/\/\/ desired state or not.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">\/\/\/<\/span><span style=\"background: white;color: gray;font-family: consolas;font-size: 9.5pt\">&lt;\/summary&gt;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">protected&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">override&nbsp;<\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">void<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> ProcessRecord()<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Implement the test method of the resource.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">}<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoListParagraph\" style=\"text-indent: -0.5in;margin-left: 38.65pt\"><span style=\"color: #0080c0\"><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">IV)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/strong><\/span><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\"> How to handle Machine reboot in C# based DSC Resources.<\/span><\/strong><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">If your resource needs a machine reboot. The way to indicate that in script-based DSC resource is setting the global variable $global:DSCMachineStatus&nbsp; to 1 in the Set-TargetResource function of the resource.&nbsp; To do similar in C#-based DSC resource, you will need to set the same variable in the runspace where the Set Cmdlet of the resource will be executed.<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">Adding the following two lines will signal a machine reboot to the DSC engine.<\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">PSVariable<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\"> DSCMachineStatus = <\/span><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">new <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">PSVariable<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">(<\/span><span style=\"background: white;color: #a31515;font-family: consolas;font-size: 9.5pt\">&#8220;DSCMachineStatus&#8221;<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">, 1, <\/span><span style=\"background: white;color: #2b91af;font-family: consolas;font-size: 9.5pt\">ScopedItemOptions<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.AllScope);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: blue;font-family: consolas;font-size: 9.5pt\">this<\/span><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">.SessionState.PSVariable.Set(DSCMachineStatus);<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"line-height: normal;margin-bottom: 0pt\"><span style=\"background: white;color: black;font-family: consolas;font-size: 9.5pt\">&nbsp;<\/span><\/p>\n<h2 class=\"WordSection1\"><strong><span style=\"color: #004080\">Consume C# based resources<\/span><\/strong><\/h2>\n<p class=\"MsoListParagraph\" style=\"margin: 0in 0in 0pt 0.75in;text-align: left;line-height: normal;text-indent: -0.5in\"><span class=\"Heading3Char\"><strong><span style=\"font-size: 12pt\">I)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/strong><\/span><span class=\"Heading3Char\"><strong><span style=\"font-size: 12pt\"><span style=\"color: #0080c0\">How to deploy C# based DSC Resource <\/span><\/span><\/strong><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\">The folder structure of C# based DSC resource is the same as the script based resource. Please refer to <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/12\/05\/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx\">this<\/a> blog to see how DSC resources should be deployed in your machine.<\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\">The output binaries from your project and the schema mof of the resource should be deployed to the correct path before you can use it to author or apply configurations.<\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\"><span style=\"line-height: 107%;font-size: 9pt\">Example: &#8211; if you deploy the resource under a module &ldquo;CSharpDSCResource&rdquo; inside $env:programfiles, the folder structure would look like:-<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\"><span style=\"line-height: 107%;font-size: 8pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $env:ProgramFiles\\WindowsPowerShell\\Modules\\CSharpDSCResource\\DSCResources\\MSFT_XDemoFile\\MSFT_XDemoFile.dll<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\"><span style=\"line-height: 107%;font-size: 8pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $env:ProgramFiles\\WindowsPowerShell\\Modules\\CSharpDSCResource\\DSCResources\\MSFT_XDemoFile\\MSFT_XDemoFile.Shema.mof<\/span><\/p>\n<p class=\"MsoListParagraph\" style=\"text-indent: -0.5in;margin-left: 0.75in\"><strong>II<\/strong>)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0080c0\"><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">Create Configuration<\/span><\/strong><\/span>:-<\/span><\/p>\n<p class=\"MsoListParagraph\" style=\"text-indent: -0.5in;margin-left: 0.75in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><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\">CsharpExample<\/span> <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">{<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp; <span style=\"color: blue\">Import-DSCResource<\/span> <span style=\"color: navy\">-Module<\/span> <span style=\"color: blueviolet\">CSharpDSCResource<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp; Node(<span style=\"color: darkred\">&#8220;localhost&#8221;<\/span>)<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xDemoFile <span style=\"color: blueviolet\">fileLog<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Path <span style=\"color: darkgray\">=<\/span> <span style=\"color: darkred\">&#8220;c:\\foo.txt&#8221;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Content <span style=\"color: darkgray\">=<\/span> <span style=\"color: darkred\">&#8220;content example&#8221;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ensure <span style=\"color: darkgray\">=<\/span> &ldquo;<span style=\"color: darkred\">Present&#8221;<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp; }<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">} <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.25in\">&nbsp;<\/p>\n<p class=\"MsoListParagraph\" style=\"text-indent: -0.5in;margin-left: 0.75in\"><span style=\"color: #2e74b5;line-height: 107%;font-family: 'Calibri Light','sans-serif';font-size: 13pt\"><strong>III<\/strong>)<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: #0080c0\"><span class=\"Heading3Char\"><strong><span style=\"line-height: 107%;font-size: 12pt\">Run the configuration<\/span><\/strong><\/span><span style=\"color: #2e74b5;line-height: 107%;font-family: 'Calibri Light','sans-serif';font-size: 13pt\">:- <\/span><\/span><\/p>\n<p class=\"MsoListParagraph\" style=\"text-indent: -0.5in;margin-left: 0.75in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"background: #012456;margin: 0in 0in 0pt 0.75in;line-height: normal\"><span style=\"color: whitesmoke;font-family: 'Lucida Console';font-size: 9pt\">Start-DSCConfiguration -ComputerName localhost -Path .\\CsharpExample\\ -Verbose -Wait <\/span><\/p>\n<div class=\"WordSection1\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/div>\n<h2 class=\"WordSection1\">&nbsp;<\/h2>\n<p class=\"MsoNormal\" style=\"text-align: justify\">Berhe Abrha<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">Windows PowerShell Team<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Components.PostAttachments\/00\/10\/52\/96\/39\/Complet_Sample_DSCResource_CSharp.zip\">Complet_Sample_DSCResource_CSharp.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In previous blog, we learned how one can use their PowerShell skills to author DSC resources very easily. Still there are folks (we met some at TechEd NA) who want to author their DSC resources using C# because they are more productive with it than PowerShell language. Well, you can fully leverage the power of [&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":[150,152,248,251,327],"class_list":["post-1661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-dsc","tag-dsc-resource-kit","tag-powershell","tag-powershell-4-0","tag-teched"],"acf":[],"blog_post_summary":"<p>In previous blog, we learned how one can use their PowerShell skills to author DSC resources very easily. Still there are folks (we met some at TechEd NA) who want to author their DSC resources using C# because they are more productive with it than PowerShell language. Well, you can fully leverage the power of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1661","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=1661"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1661\/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=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}