{"id":1701,"date":"2014-04-25T15:04:00","date_gmt":"2014-04-25T15:04:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2014\/04\/25\/understanding-import-dscresource-keyword-in-desired-state-configuration\/"},"modified":"2019-02-18T13:05:20","modified_gmt":"2019-02-18T20:05:20","slug":"understanding-import-dscresource-keyword-in-desired-state-configuration","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/understanding-import-dscresource-keyword-in-desired-state-configuration\/","title":{"rendered":"Understanding Import-DscResource Keyword in Desired State Configuration"},"content":{"rendered":"<div class=\"WordSection1\">\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">Desired State Configuration resources are used to model and change the state of different components of the system. In an earlier&nbsp;<\/span><span style=\"font-size: medium\"><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/12\/05\/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx\">blog post<\/a><\/span><span style=\"line-height: 107%;font-size: 12pt\">, we discussed details about deploying and discovering those resources and introduced <strong>Import-DscResource<\/strong> dynamic keyword. In this post, we will discuss some more details about the usage and internal working of this dynamic keyword. &nbsp;This keyword is only available inside configuration block. Its syntax looks like PowerShell cmdlet but it&rsquo;s not a cmdlet and behaves differently.&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">When authoring the DSC configuration in ISE, the PowerShell parser, provides IntelliSence for resources and resource properties by auto loading the resource definitions from $pshome module path. Moreover, the same resource definitions are used during compilation step (generation of MOF document) to validate the entries of the configuration. E.g. resource schema validation is done for following:<\/span><\/p>\n<ul>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 106%;text-indent: -0.25in\"><span style=\"line-height: 106%;font-family: Symbol;font-size: 12pt\"><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"line-height: 106%;font-size: 12pt\">Only properties defined in schema are used<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 106%;text-indent: -0.25in\"><span style=\"line-height: 106%;font-family: Symbol;font-size: 12pt\"><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"line-height: 106%;font-size: 12pt\">The data types for each property is correct <br \/><\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 106%;text-indent: -0.25in\"><span style=\"line-height: 106%;font-family: Symbol;font-size: 12pt\"><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"line-height: 106%;font-size: 12pt\">Keys properties are specified<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 106%;text-indent: -0.25in\"><span style=\"line-height: 106%;font-family: Symbol;font-size: 12pt\"><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"line-height: 106%;font-size: 12pt\">No read only property is used<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 106%;text-indent: -0.25in\"><span style=\"line-height: 106%;font-size: 12pt\">&nbsp;&nbsp;<\/span><span style=\"line-height: 106%;font-family: Symbol;font-size: 12pt\"><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"line-height: 106%;font-size: 12pt\">Validation on value maps types <\/span><\/div>\n<\/li>\n<\/ul>\n<p class=\"MsoNormal\" style=\"text-align: justify;text-indent: 0.25in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;text-indent: 0.00in\"><span style=\"line-height: 107%;font-size: 12pt\">Consider this configuration:<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;text-indent: 0.25in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;text-indent: 0.25in;margin-bottom: 0pt;padding-left: 30px\"><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\">SchemaValidationInCorrectEnumValue<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;text-indent: 0.25in;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">{ <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: darkblue\">WindowsFeature<\/span> <span style=\"color: blueviolet\">ROLE1<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&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=\"background: none repeat scroll 0% 0% white;line-height: normal;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name <span style=\"color: darkgray\">=<\/span> <span style=\"color: darkred\">&#8220;Telnet-Client&#8221;<\/span> <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ensure <span style=\"color: darkgray\">=<\/span> <span style=\"color: darkred\">&#8220;Invalid&#8221;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: none repeat scroll 0% 0% white;line-height: normal;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&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=\"background: none repeat scroll 0% 0% white;line-height: normal;text-indent: 0.25in;margin-bottom: 0pt;padding-left: 30px\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">} <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;line-height: 12pt\"><span style=\"font-family: 'Lucida Console';font-size: 9pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">Compiling it will result in error:<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.25in;padding-left: 30px\"><em><span style=\"line-height: 107%;font-size: 12pt\">PSDesiredStateConfiguration\\WindowsFeature: At least one of the values &#8216;Invalid&#8217; is not supported or valid for property &#8216;Ensure&#8217; on class &#8216;WindowsFeature&#8217;. Please specify only supported values: Present, Absent.<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">This allows catching most of the errors during parse and compilation time instead of delaying it till run time (configuration application). <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">DSC provides a mechanism to add new <\/span><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/11\/19\/resource-designer-tool-a-walkthrough-writing-a-dsc-resource.aspx\"><span style=\"line-height: 107%;font-size: 12pt\">custom DSC resources<\/span><\/a><span style=\"line-height: 107%;font-size: 12pt\">. These resources should be deployed outside of $pshome module path, preferably under $env:SystemDrive\\Program Files\\WindowsPowerShell\\Modules path. For configuration that use custom DSC resources, authoring and compilation steps need to know the additional resources that should be loaded for validation &ndash; that&rsquo;s where Import-DscResource comes into play. In absence of an import mechanism, parsing and compilation steps could be very slow because they have to look up entire $PSModulePath entries to find module containing required DSC resource. Also Import-DscResource is used to import both <\/span><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/02\/25\/reusing-existing-configuration-scripts-in-powershell-desired-state-configuration.aspx\"><span style=\"line-height: 107%;font-size: 12pt\">composite<\/span><\/a><span style=\"line-height: 107%;font-size: 12pt\"> and PowerShell DSC resources.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><strong><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/strong><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><strong><span style=\"line-height: 107%;font-size: 12pt\">Import-DscResource<\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\"> currently supports two non-positional parameters <strong>Name<\/strong> and <strong>ModuleName<\/strong>.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><strong><span style=\"line-height: 107%;font-size: 12pt\">-Name <\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\">is the name of the resource to import. The name of the resource has to be the class name used when defining schema for the resource and not the friendly name. E.g. <\/span><\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"margin-left: 1in\"><em><span style=\"color: #2f5496;line-height: 107%;font-size: 12pt\">[ClassVersion(&#8220;1.1.0&#8221;),FriendlyName(&#8220;Website&#8221;)] <\/span><\/em><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin-left: 1in\"><em><span style=\"color: #2f5496;line-height: 107%;font-size: 12pt\">class WebsiteResource : OMI_BaseResource<\/span><\/em><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin-left: 1in\"><em><span style=\"color: #2f5496;line-height: 107%;font-size: 12pt\">{<\/span><\/em><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin-left: 1in\"><em><span style=\"color: #2f5496;line-height: 107%;font-size: 12pt\">}<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">In above example resource name is <em><span style=\"color: black\">WebsiteResource<\/span> <\/em>and not the friendly name &ldquo;Website&rdquo;.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">Name can contain any numbers of resources to be imported.&nbsp; If only &ndash;Name parameter is used then resources can belong to different PowerShell modules as well. e.g. <\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin-left: 1in\"><em><\/em>&nbsp;<em><span style=\"color: #2f5496;line-height: 107%;font-size: 12pt\">Import-DSCResource &ndash;Name MSFT_xADDomain , MSFT_xSmbShare&nbsp;&nbsp;&nbsp;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">The above command will loop through all modules installed in all paths in $env:PSModulePath to find the ones containing resources whose names are specified as value for &ndash;Name parameter. Things to consider when using only the Name parameter: &nbsp;<\/span><\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"text-align: justify;text-indent: -0.25in;margin-left: 1in\"><strong><span style=\"line-height: 107%;font-size: 12pt\">1-<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp; <\/span><\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\">It has performance implications because it is resource intensive operation. It can use lots of memory on machine depending on how many modules are installed on machine.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-align: justify;text-indent: -0.25in;margin-left: 1in\"><strong><span style=\"line-height: 107%;font-size: 12pt\">2-<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp; <\/span><\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\">It will load the first resource found with given name so in case there are more than one resource with same name deployed on machine, it can end up loading different resource then the one desired. <\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><span style=\"line-height: 107%;font-size: 12pt\">The recommended way is to specify &ndash;ModuleName as well as described below.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"text-align: justify\"><strong><span style=\"line-height: 107%;font-size: 12pt\">-ModuleName<\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\"> is the name of the module that contains the resources to be imported. &nbsp;This parameter can contain either string array of module names or modules specification object.&nbsp; e.g.<\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin-left: 1in\"><em><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">Import-DSCResource &ndash;ModuleName&nbsp; xActiveDirectory, xSmbShare&nbsp;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">Above command will import all resources defined inside modules xActiveDirectory and xSmbShare unless we specify &ndash;Name parameter as well to only load selected resources.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">Module specification object is just a hash table. The valid members that can be added to it are ModuleName, ModuleVersion and GUID.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in;margin-left: 0.5in\"><em><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">Import-DscResource &ndash;ModuleName @{ModuleName=&#8221;xActiveDirectory&rdquo;},@{ModuleName=&#8221; xSmbShare&#8221;}<\/span><\/em><\/p>\n<p class=\"MsoNormal\"><strong><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/strong><\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">The<\/span><strong><span style=\"line-height: 107%;font-size: 12pt\"> Import-DscResource<\/span><\/strong><span style=\"line-height: 107%;font-size: 12pt\"> command only tries to find resources inside specific module when ModuleName parameter is specified, which solves any delays\/performance issues during resource discovery. Also its lets user control which exact version of module to load when there are multiple versions of same module installed on machine. <\/span><\/p>\n<p class=\"MsoNormal\"><strong><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/strong><\/p>\n<p class=\"MsoNormal\"><strong><\/strong>&nbsp;<\/p>\n<p class=\"MsoNormal\"><strong><span style=\"line-height: 107%;font-size: 14pt\">DSC Resource Versioning&nbsp; <\/span><\/strong><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">DSC resources have same version as that of container Modules. Version is determined by ModuleVersion property defined in .psd1 of container module. DSC resources can also define their own .psd1 file which might have ModuleVersion defined as well, but version property is used from container module .psd1 to load resources.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">Any updates in resources should result in update to container module version and configuration author can select which version of Resource\/Module to load by using command like: <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">&nbsp; <em>Import-DscResource -ModuleName @{ModuleName=&#8221;xActiveDirectory&rdquo;;GUID=&#8221;caedd1418493-4af3-bda0-eef11e9ca2be&rdquo;;ModuleVersion=&#8221;2.0&#8243;},@{ModuleName=&#8221; xSmbShare&#8221;;ModuleVersion=&#8221;1.0&#8243;}<\/em><\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">Above command will fail if it is not able to find exact module version for each module. <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">The Module version number along with module name is included in each resource instance in output MOF generated during compilation. It looks like this:&nbsp;&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">instance of MSFT_xADDomain as $MSFT_xADDomain1ref <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">{<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ResourceID = &#8220;[xADDomain]FirstDS&#8221;;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"background: yellow\">ModuleName = &#8220;xActiveDirectory&#8221;;<\/span><\/span>&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"background: yellow;line-height: 107%;font-size: 12pt\">ModuleVersion = &#8220;2.0&#8221;;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><span style=\"line-height: 107%;font-size: 12pt\">}<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">This gives the LCM information about which version of resource was used to generate the MOF. That is the version against which we validated resource properties during compilation so LCM attempts to find\/load the same version at runtime. Incase same version does not exist on target node, execution behavior is different for <\/span><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/11\/26\/push-and-pull-configuration-modes.aspx\"><span style=\"line-height: 107%;font-size: 12pt\">Push vs Pull configuration modes<\/span><\/a><span style=\"line-height: 107%;font-size: 12pt\">. In case of Push mode execution fails and error is returned to user pushing the configuration. For Pull mode LCM attempts to download required module from Pull server and installs it on target node before execution, if it is unable to find that version on pull server execution fails. <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><strong><span style=\"line-height: 107%;font-size: 14pt\">Support for Wild Card operator and Partial Parameter Names <\/span><\/strong><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">Import-DSCResource also supports partial parameter names <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><em><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">Import-DscResource -N MSFT_xADDomain -Mod &#8221; xActiveDirectory &#8220;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">We can also use wildcard while specifying resource Names <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><em><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">Import-DscResource -Name * -ModuleName =&#8221;xActiveDirectory&rdquo;;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><em><span style=\"color: #0070c0;line-height: 107%;font-size: 12pt\">Import-DscResource -Name MSFT* &nbsp;-ModuleName =&#8221;xActiveDirectory&rdquo;;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">Wildcards are not supported for &ndash;ModuleName parameter because value can map to multiple module names and is error prone. Below command <span style=\"color: black\">will result in error during configuration compilation. <\/span><\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><em><span style=\"color: #2e74b5;line-height: 107%;font-size: 12pt\">Import-DscResource -Name * -ModuleName UserConfigPro*<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\"><span style=\"line-height: 107%;font-size: 12pt\">Also specifying multiple values for Resource names and modules names in same command are not supported. It can have non-deterministic behavior about which resource to load from which module in case same resource exists in multiple modules. Below command will result in error during compilation as well. <\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in\"><em><span style=\"color: #2e74b5;line-height: 107%;font-size: 12pt\">Import-DscResource -Name UserConfigProvider*,TestLogger1 -ModuleName UserConfigProv,PsModuleForTestLogger<\/span><\/em><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"background: white;line-height: normal;margin-bottom: 0pt\"><span style=\"color: #424242;font-size: 12pt\" lang=\"EN\">Fayza Sultan &nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: white;line-height: normal\"><span style=\"color: #424242;font-size: 12pt\" lang=\"EN\">PowerShell Team<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"line-height: 107%;font-size: 12pt\">&nbsp;<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Desired State Configuration resources are used to model and change the state of different components of the system. In an earlier&nbsp;blog post, we discussed details about deploying and discovering those resources and introduced Import-DscResource dynamic keyword. In this post, we will discuss some more details about the usage and internal working of this dynamic keyword. [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[142,150,251,345,348],"class_list":["post-1701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-desired-state-configuration","tag-dsc","tag-powershell-4-0","tag-windows-powershell-4-0","tag-windows-powershell-desired-state-configuration"],"acf":[],"blog_post_summary":"<p>Desired State Configuration resources are used to model and change the state of different components of the system. In an earlier&nbsp;blog post, we discussed details about deploying and discovering those resources and introduced Import-DscResource dynamic keyword. In this post, we will discuss some more details about the usage and internal working of this dynamic keyword. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1701","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=1701"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1701\/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=1701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}