DSC Configurations

DSC Configurations are the scripts of PowerShell, which define a special type of function. We use the keyword Configuration to define the configuration.

Syntax of DSC Configuration

The configuration script consists of the following parts:

  • The configuration block: It is the outermost block of the script. We can define it by using the keyword configuration and providing a name.
  • One or more node block: These blocks define those nodes which you are configuring.
  • One or more resource block: These are the blocks where the configuration sets the properties for those resources which are configuring.

Example: In this example, we can specify the name of the node by passing the parameter computerName when we compile the configuration.

Configuration MyDscConfiguration  

{  

    Param  

    (  

        [string[]]$ComputerName='localhost'  

    )  

    Node $ComputerName  

    {  

        WindowsFeature MyFeatureInstance  

        {  

            Ensure = 'Present'  

            Name = 'RSAT'  

        }  

        WindowsFeature My2ndFeatureInstance  

        {  

            Ensure = 'Present'  

            Name = 'Bitlocker'  

        }

Type the following command to get the output of above example:

MyDscConfiguration  

Output:

Directory: C:\MyDscConfiguration  

Mode                LastWrite Time         Length Name  

----                      -------------                   ------     ---  

-a----                 18-11-2019   16:16     2554    localhost.mof

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *