{"id":67428,"date":"2016-08-23T15:21:53","date_gmt":"2016-08-23T15:21:53","guid":{"rendered":"https:\/\/www.simple-talk.com\/?p=67428"},"modified":"2016-08-23T15:21:53","modified_gmt":"2016-08-23T15:21:53","slug":"powershell-desired-state-configuration-dsc-resources","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/sysadmin\/powershell\/powershell-desired-state-configuration-dsc-resources\/","title":{"rendered":"PowerShell Desired State Configuration: DSC Resources"},"content":{"rendered":"<ul class=\"series-articles\">\n<li>PowerShell Desired State Configuration &#8211; Part 1: <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/powershell\/powershell-desired-state-configuration-the-basics\/\">The Basics<\/a><\/li>\n<li>PowerShell Desired State Configuration &#8211; Part 2: <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/powershell\/powershell-desired-state-configuration-lcm-and-push-management-model\/\">LCM and Push Management Model<\/a><\/li>\n<li>PowerShell Desired State Configuration &#8211; Part 3: <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/powershell\/powershell-desired-state-configuration-pull-mode\/\">Pull Mode<\/a><\/li>\n<li>PowerShell Desired State Configuration &#8211; Part 4: <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/powershell\/powershell-desired-state-configuration-automating-and-monitoring-pull-mode\/\">Automating and Monitoring Pull Mode<\/a><\/li>\n<li class=\"series-articles--active\"><span class=\"icon--chevron-right\">PowerShell Desired State Configuration &#8211; Part 5: DSC Resources<\/span><\/li>\n<\/ul>\n<p>Desired State Configuration (DSC) allows us to simply define what needs to be configured on one or more machines. To achieve this, DSC is based on the concept of \u2018resource\u2019. A DSC \u2018resource\u2019 is used in a DSC configuration to perform an action on a DSC node. In effect, a resource corresponds to what can be configured on a node. We mentioned in the first article of this series that there are several resources provided by default with DSC. These built-in resources are called &#8220;official&#8221; resources and can be listed using the following command:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true \">  PS &gt; Get-DscResource |select Name,Module,Properties | Ft \u2013AutoSize\r\n<\/pre>\n<p>Official resources are added to each new version of DSC after being tested by the PowerShell team to eliminate possible bugs. However, these resources are likely to be too limited for your mundane requirements. Desired State Configuration has been designed to be extendable, and so there are two other types of resources that can be used. This allows us to create resources that do what we need without having to wait for the next versions of DSC, and we can manually add DSC resources via the \u2018Resource Kits\u2019. There are several types of kits.<\/p>\n<ul>\n<li><strong>Official Resource Kits<\/strong>: We just mentioned them &#8211; they are resources that are tested and validated by the PowerShell team and distributed with DSC. Some examples are: Group, Package, Registry, &#8230;<\/li>\n<li><strong>Experimental Resource Kits<\/strong>: As the name suggests, these are experimental resources and therefore are untested and not validated. These resources are mainly obtained via the \u2018<a href=\"http:\/\/www.powershellgallery.com\/\">PowerShell Gallery<\/a>\u2019 website which is the central repository for PowerShell content or via the \u2018<a href=\"https:\/\/github.com\/powershell\/\">PowerShell Git<\/a>\u2019. So be careful when using them, especially if you use them in a production environment. These resources have a specific naming convention because their name must begin with an &#8220;X&#8221;. Some examples are: xAzure, xHyper-V, xSQLServer, &#8230;<\/li>\n<li><strong>Community Resource Kits<\/strong>: It is noticeable that the DSC community is growing steadily and more and more content is made available by contributors. Anyone can contribute by creating their own DSC resources. They can be obtained on forums and the Git repository. Perhaps even you or your colleagues could provide them. As we shall see in this chapter, anyone can develop their own resource very easily. These resources also have a specific naming convention in that their name must begin with the letter &#8220;C&#8221;. Some examples are: cFailoverCluster, cSystemCenterManagement, &#8230;<\/li>\n<\/ul>\n<div class=\"note\">\n<p>Note: Microsoft recommends that, when editing an official or experimental resources, you should rename it with the prefix letter &#8220;c&#8221; to avoid confusion.<\/p>\n<\/div>\n<p>I recommend that you regularly follow the <a href=\"https:\/\/blogs.msdn.microsoft.com\/powershell\/\">PowerShell team blog<\/a> in order to stay informed of the release of the latest DSC resources.<\/p>\n<h2>What is a DSC Resource?<\/h2>\n<p>A DSC resource is similar to a Windows PowerShell module. This type of module regroups one or more resources and contains several elements:<\/p>\n<ul>\n<li><strong>The scheme<\/strong>: This is the definition of configurable properties, held in a MOF file named \u2018.schema.mof\u2019<\/li>\n<li><strong>The implementation<\/strong>: This is the code that configures the node via the DSC configuration. It is held in a script module with the extension of .psm1. There can also be the .psd1 file which contains the manifest, but it is not mandatory.<\/li>\n<\/ul>\n<p>An example is worth a thousand words \u2013 so let us analyze the &#8220;xHyper-V&#8221; resource:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p><strong>Module Name<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Version<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Sub-Folders or Files<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>DSCResources<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>DSC Resource Files<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>xHyper-V<\/p>\n<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\n<p>3.4.0.0<\/p>\n<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\n<p>DSCResources<\/p>\n<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\n<p>xVHD<\/p>\n<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\n<p>xVHD.psm1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<td>\n<p>xVHD.schema.mof<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><strong>Module Name<\/strong>: This is the official name of the module from which you can search.<\/li>\n<li><strong>Version<\/strong>: This is the version of the module. It allows you to identify new versions before using the &#8220;<strong>Update-Module<\/strong>&#8221; cmdlet to install the new version.<\/li>\n<li><strong>Sub-Folders or Files<\/strong>: This directory contains at least a &#8220;<strong>DSCResources<\/strong>&#8221; subdirectory, but probably more containing such files as examples, the license, the readme file or the documentation<\/li>\n<li><strong>DSCResources<\/strong>: This directory is the most interesting because it contains the PowerShell scripts that will be used to configure nodes. It is a good idea to indulge your natural curiosity by opening them up to better understand the resource.<\/li>\n<\/ul>\n<h2>Installing a DSC Resource<\/h2>\n<p>Now to practice. It requires no special skills to Install a DSC resource. It is very simple. Basically, you just copy and paste files into a folder. To know where to copy the resources, use the following command:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Get-ChildItem -Path Env:\\PSModulePath | select value | fl *\r\n<\/pre>\n<p>The first step is to search our module, and there are several methods for doing this. WMF 5.0 provides the &#8220;<strong>Find-Module<\/strong>&#8221; cmdlet which is part of the &#8220;<strong>PowerShellGet<\/strong>&#8221; module. This will search directly in the modules available on the site \u2018PowerShell Gallery\u2019 site:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Find-Module -Includes DscResource \u2013Verbose\r\n<\/pre>\n<p>You can also list the modules that contain the tag \u201c<strong>DSCResourceKit<\/strong>\u201d.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Find-Module -Tag DSCResourceKit\r\n<\/pre>\n<p>Finally, the &#8220;<strong>Find-DSCResource<\/strong>&#8221; cmdlet can also be used. Don\u2019t confuse this with the \u2018<strong>Get-DSCResources<\/strong>\u2019 cmdlet that lists the resources that are present locally on the machine.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Find-DSCResource\r\n<\/pre>\n<p>A manual search on the PowerShell Gallery website will also allow you to search for resources:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2016\/08\/word-image-440.png\" \/><\/p>\n<p class=\"caption\">Figure 1 \u2013 PowerShell Gallery website<\/p>\n<div class=\"note\">\n<p>Note: It is possible to save the module on your machine to analyze it before installation. For this, use the &#8220;<strong>Save-Module<\/strong>&#8221; cmdlet:<\/p>\n<\/div>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Save-Module -Name xSQLServer -Path C:\\TEMP\\DSCResources\\SQL\\\r\n<\/pre>\n<p>To install the module, you will need administrator privileges on your workstation. Run the following command to install, by example, the <strong>xSQLServer<\/strong> module:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Install-Module -Name xSQLServer\r\n<\/pre>\n<p>The module is copied to the <code>$env:ProgramFiles\\WindowsPowerShell\\Modules<\/code>. If you do not have administrator account, then you must add the following parameter: \u201c-<strong>Scope CurrentUser<\/strong>\u201d. The module will be installed into the following directory: <code>C:\\Users\\%USERNAME%\\Documents\\WindowsPowerShell\\<\/code><\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Install-Module -Name xPendingReboot -Scope currentuser\r\n<\/pre>\n<p>If you have a previous version of the module, then you can update it via the \u201c<strong>Update-Module<\/strong>\u201d cmdlet.<\/p>\n<p>Remember that, in the case of push mode, the resource must be present on each node that you want to configure. This is in contrast to the pull mode, where the resource must be present only on the Pull Server.<\/p>\n<h2>Using a DSC Resource<\/h2>\n<p>Before you use a DSC resource, you need to understand how it works and know the available properties. Let us start by the <strong>Get-DSCResource <\/strong>cmdlet which will list DSC Resources:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS C:\\&gt; Get-DscResource Package | select -ExpandProperty Properties\r\n\r\nName                 PropertyType   IsMandatory Values\r\n----                 ------------   ----------- ------\r\nName                 [string]              True {}\r\nPath                 [string]              True {}\r\nProductId            [string]              True {}\r\nArguments            [string]             False {}\r\nCredential           [PSCredential]       False {}\r\nDependsOn            [string[]]           False {}\r\nEnsure               [string]             False {Absent, Present}\r\nLogPath              [string]             False {}\r\nPsDscRunAsCredential [PSCredential]       False {}\r\nReturnCode           [UInt32[]]           False {}\r\n<\/pre>\n<p>The following configuration use the &#8220;Package&#8221; resource in the push mode:<\/p>\n<pre>Configuration Install7Zip\r\n{\r\n    Node $env:ComputerName\r\n    {\r\n        Package 7Zip\r\n        {\r\n            Ensure = 'Present'\r\n            Name = '7-Zip 9.20 (x64 edition)'\r\n            Path = 'C:\\DSC\\Package\\7Zip\\7z920-x64.msi'\r\n            ProductId = '23170F69-40C1-2702-0920-000001000000'\r\n        }\r\n    }\r\n}\r\n\r\nInstall7Zip -OutputPath C:\\DSC\\Package\\7Zip\r\n\r\nStart-DscConfiguration -Path C:\\DSC\\Package\\7Zip -wait -verbose -Force\r\n<\/pre>\n<ul>\n<li>The <strong>ensure<\/strong> parameter installs or uninstalls the package.<\/li>\n<li>The <strong>path<\/strong> parameter indicates the location of the 7Zip executable.<\/li>\n<li>The <strong>ProductID<\/strong> allows to detect if the package is installed correctly or not.<\/li>\n<\/ul>\n<p>To obtain this <strong>ProductID<\/strong>, the most common method is to manually install the package and then get the <strong>ID<\/strong> in the registry:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Gci HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\r\n<\/pre>\n<p>As a sysadmin, I use SCCM to manage all my machines. So my tip is to use SCCM to easily get the <strong>ProductID<\/strong> from the application deployment tab. This avoids me from unnecessarily installing the software on a machine.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2016\/08\/word-image-441.png\" \/><\/p>\n<p class=\"caption\">Figure 2 \u2013 SCCM Application<\/p>\n<p>Furthermore, I advise you to use shared folders to centralize your packages and so to easily access them from your nodes.<\/p>\n<p>A reboot may be required after installing or uninstalling (<strong>Ensure = Absent<\/strong>).<\/p>\n<p>The installation time is extremely fast! Installing 7Zip is done in 2.2 seconds and the uninstallation in 8 seconds.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">Directory: C:\\Package\\7Zip\r\n\r\n\r\nMode                LastWriteTime     Length Name\r\n----                -------------     ------ ----\r\n-a---         7\/23\/2016  11:12 PM       1310 dsc01.mof\r\nVERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root\/Microsoft\/Windows\/DesiredStateConfiguration'.\r\nVERBOSE: An LCM method call arrived from computer DSC01 with user sid S-1-5-21-2287797765-438078933-1\r\n308532817-1227.\r\nVERBOSE: [DSC01]: LCM:  [ Start  Set      ]\r\nVERBOSE: [DSC01]: LCM:  [ Start  Resource ]  [[Package]7Zip]\r\nVERBOSE: [DSC01]: LCM:  [ Start  Test     ]  [[Package]7Zip]\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] The package 7-Zip 9.20 (x64 edition) is not installed\r\nVERBOSE: [DSC01]: LCM:  [ End    Test     ]  [[Package]7Zip]  in 0.0310 seconds.\r\nVERBOSE: [DSC01]: LCM:  [ Start  Set      ]  [[Package]7Zip]\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] The package 7-Zip 9.20 (x64 edition) is not installed\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] Package configuration starting\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] The machine requires a reboot\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] Package has been installed\r\nVERBOSE: [DSC01]:                            [[Package]7Zip] Package configuration finished\r\nVERBOSE: [DSC01]: LCM:  [ End    Set      ]  [[Package]7Zip]  in 2.2190 seconds.\r\nVERBOSE: [DSC01]: LCM:  [ End    Resource ]  [[Package]7Zip]\r\nVERBOSE: [DSC01]:                            [] A reboot is required to progress further. Please reboot the system.\r\nVERBOSE: [DSC01]: LCM:  [ End    Set      ]\r\nVERBOSE: [DSC01]: LCM:  [ End    Set      ]    in  2.3600 seconds.\r\nVERBOSE: Operation 'Invoke CimMethod' complete.\r\nVERBOSE: Time taken for configuration job to complete is 2.377 seconds\r\n<\/pre>\n<p>Now, let\u2019s look at an example of the experimental resource. We will create a VHD file with the <strong>xHyper-V <\/strong>resource:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true\">configuration NewVHD \r\n{ \r\n    param \r\n    ( \r\n        [Parameter(Mandatory)] \r\n        [string]$Name, \r\n         \r\n        [Parameter(Mandatory)] \r\n        [string]$Path, \r\n                 \r\n        [Parameter(Mandatory)] \r\n        [Uint64]$MaximumSizeBytes, \r\n \r\n        [ValidateSet(\"Vhd\",\"Vhdx\")] \r\n        [string]$Generation = \"Vhd\", \r\n \r\n        [ValidateSet(\"Present\",\"Absent\")] \r\n        [string]$Ensure = \"Present\"         \r\n    ) \r\n \r\n    Import-DscResource -module xHyper-V \r\n \r\n    Node HYPV01 \r\n    { \r\n\tWindowsFeature HyperV\r\n        {\r\n            Ensure = 'Present'\r\n            Name   = 'Hyper-V'\r\n        }\r\n\tFile VMFolder\r\n        {\r\n            DestinationPath = (Join-Path -Path C:\\Scripts\\VHDs -ChildPath $($Name))\r\n            Ensure = \"Present\"\r\n            Force = $True\r\n            Type = \"Directory\"\r\n        }\r\n        \r\n\txVHD NewVHD \r\n        { \r\n            Ensure           = $Ensure \r\n            Name             = \"$($Name)_DISK1\" \r\n            Path             = (Join-Path -Path C:\\Scripts\\VHDs -ChildPath $($Name))\r\n            Generation       = $Generation \r\n            MaximumSizeBytes = $MaximumSizeBytes \r\n            DependsOn        = \"[File]VMFolder\"\r\n        } \r\n    } \r\n}\r\n<\/pre>\n<p>This example allows me to focus on an important line:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true\">      Import-DscResource -module xHyper-V \r\n<\/pre>\n<p><strong>Import-DscResource<\/strong> could be mistaken for a PowerShell cmdlet, but it is actually a keyword that can be used only in a DSC configuration. It allows us to load the xHyper-V resources needed to configure the node.<\/p>\n<h2>Creating a DSC Resource<\/h2>\n<p>For specific needs, you will probably need to create your own resources. Writing a DSC resource is carried out with the aid of the <strong>xDscResourceDesigner<\/strong> module that provides several cmdlets in order to simplify the process.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">  PS &gt; Find-Module xDscResourceDesigner\r\n<\/pre>\n<p>Let us view the available cmdlets in this module:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; get-command -module xDscResourceDesigner\r\n\r\nCommandType     Name                                     Version    Source\r\n-----------     ----                                     -------    ------\r\nFunction        Import-xDscSchema                        1.9.0.0    xDscResourceDesigner\r\nFunction        New-xDscResource                         1.9.0.0    xDscResourceDesigner\r\nFunction        New-xDscResourceProperty                 1.9.0.0    xDscResourceDesigner\r\nFunction        Test-xDscResource                        1.9.0.0    xDscResourceDesigner\r\nFunction        Test-xDscSchema                          1.9.0.0    xDscResourceDesigner\r\nFunction        Update-xDscResource                      1.9.0.0    xDscResourceDesigner\r\n<\/pre>\n<p>We will begin by creating our resource properties via the <strong>New-xDscResourceProperty<\/strong> cmdlet:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true\"># Define DSC resource properties \r\n \r\n$Property1 = New-xDscResourceProperty -Name Prop1 -Type String -Attribute Key\r\n$Property2 = New-xDscResourceProperty -Name Prop2 -Type String -Attribute Write -ValidateSet \"Present\", \"Absent\"\r\n$Property3 = New-xDscResourceProperty -Name Prop3 -Type String -Attribute Required\r\n<\/pre>\n<p>We can now create our resource by integrating the above properties:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true\"># Create the DSC resource \r\n \r\nNew-xDscResource -Name cMyDscResource `\r\n\t\t    -Property $Property1,$Property2,$Property3 `\r\n\t           -Path \"$env:ProgramFiles\\WindowsPowerShell\\Modules\" `\r\n\t           -ModuleName cMyDscModule \r\n<\/pre>\n<p>We\u2019ll now execute these lines. Below is the output:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">    Directory: C:\\Program Files\\WindowsPowerShell\\Modules\r\n\r\nMode                LastWriteTime         Length Name\r\n----                -------------         ------ ----\r\nd-----       24.07.2016     15:22                cMyDscModule\r\n\r\n    Directory: C:\\Program Files\\WindowsPowerShell\\Modules\\cMyDscModule\r\n\r\nMode                LastWriteTime         Length Name\r\n----                -------------         ------ ----\r\nd-----       24.07.2016     15:22                DSCResources\r\n\r\n    Directory: C:\\Program Files\\WindowsPowerShell\\Modules\\cMyDscModule\\DSCResources\r\n\r\nMode                LastWriteTime         Length Name\r\n----                -------------         ------ ----\r\nd-----       24.07.2016     15:22                cMyDscResource\r\n<\/pre>\n<p>The tree view of your module is created automatically by PowerShell and some files are now present.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2016\/08\/word-image-442.png\" \/><\/p>\n<p>The most important is the .psm1 file which contains the following three functions that you must implement:<\/p>\n<ul>\n<li><span style=\"color: darkblue;\">Function<\/span> <span style=\"color: purple;\">Get-TargetResource<\/span> { <span style=\"color: green;\"># Gather information about the task<\/span> }<\/li>\n<li><span style=\"color: darkblue;\">Function<\/span> <span style=\"color: purple;\">Set-TargetResource<\/span> { <span style=\"color: green;\"># Apply what we want to do<\/span> }<\/li>\n<li><span style=\"color: darkblue;\">Function<\/span> <span style=\"color: purple;\">Test-TargetResource<\/span> { <span style=\"color: green;\"># Test the system<\/span> }<\/li>\n<li>Export the module at the end of the file: <span style=\"color: blue;\">Export-ModuleMember<\/span> <span style=\"color: darkblue;\">-Function <span style=\"color: purple;\">*<\/span> -TargetResource <\/span><\/li>\n<\/ul>\n<p>Finally, let us check that our module is available on the machine:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; Get-Module -ListAvailable | ? Name -like \"cM*\"\r\n\r\n\r\n    Directory: C:\\Program Files\\WindowsPowerShell\\Modules\\CustomResources\r\n\r\n\r\nModuleType Version    Name                                ExportedCommands\r\n---------- -------    ----                                ----------------\r\nManifest   1.0        cMyDscModule\r\n<\/pre>\n<p>And also the DSC resource:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; Get-DscResource -Name \"cMy*\"\r\n\r\nImplementedAs   Name             ModuleName    Version   Properties\r\n-------------   ----             ----------    -------   ----------\r\nPowerShell      cMyDscResource   cMyDscModule  1.0       {Prop1, Prop3, DependsOn, Prop2...}\r\n<\/pre>\n<p>Now you can run a DSC configuration with your own DSC resource! Don\u2019t forget to load your module:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true \">  Import-DscResource -module cMyDscModule \r\n<\/pre>\n<h2>Conclusion<\/h2>\n<p>With this series of articles now completed, I advise you, as usual, to take the examples and adapt them to your network environment to become familiar with this new DSC concept.<\/p>\n<p>We saw in this series the DSC resource that is the backbone of Desired State Configuration. We have imported new resources but also created customs resources to meet specific needs.<\/p>\n<p>Before writing your own resources, I suggest that you first browse the experimental resources as there are many. Keep in mind that the DSC mode you choose will have only one impact on the resources that you use:<\/p>\n<ul>\n<li>In Push mode, it will be mandatory to deploy the resources on the nodes that must be configured.<\/li>\n<li>In Pull mode, the resources must only be on the Pull server so that nodes can download them.<\/li>\n<\/ul>\n<p>DSC is a very powerful tool but requires some practice to use it properly. Thus the verbose mode will allow you to effectively analyze possible configuration deployment errors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Desired State Configuration (DSC) allows you to automate the way that you manage configuration data for software services as well as the environment in which these services run.  DSC uses a set of built-in and custom &#8216;resources&#8217; as the building blocks for a configuration. if you have specific requirements you may need to create the relevant resource to make the configuration happen.  Nicolas Prigent provides a practical guide to DSC resources&hellip;<\/p>\n","protected":false},"author":158223,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[35],"tags":[],"coauthors":[6804],"class_list":["post-67428","post","type-post","status-publish","format-standard","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/67428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/158223"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=67428"}],"version-history":[{"count":5,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/67428\/revisions"}],"predecessor-version":[{"id":67437,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/67428\/revisions\/67437"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=67428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=67428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=67428"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=67428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}