TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell DSC

PowerShell DSC with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell DSC

The Desired State Configuration (DSC) is a management platform in a PowerShell that is used for development, configuration, and management of systems. PowerShell DSC was introduced in version 4.0. So, if you want to use it, you need a version 4.0 or above of PowerShell. It is available on Linux, Windows, and Nano Server.

It provides a collection of PowerShell language extensions, cmdlets, and a process called declarative scripting.

It mainly consists of three components:

  • Configurations
  • Resources
  • Local Configuration Manager (LCM)

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

DSC Resources

The resources of desired state configuration provide the building blocks for the DSC configuration. The following are the basic built-in configuration resources of the Desired State Configuration:

  • File: This resource is used to manage the files and folders on a node.
  • Archive: It is used to decompress an archive in the .zip format.
  • Registry: It manages the registry key of a node (except HKEY Users).
  • Script: It is used to execute several PS commands on a node.
  • User: This is used to manage a local user on a node.
  • Log: The log resource writes a message in the DSC event log.
  • Package: This resource installs or removing a package.
  • WindowsFeature: It adds or removes a feature on a node.
  • WindowsOptionalFeature: This resource adds or removes an optional feature.
  • WindowsProcess: This resource of DSC manages a Windows process.
  • Service: It is used to manage Windows services such as State, Startup Type.
  • Environment: It manages system environment variables.

DSC Local Configuration Manager (LCM)

It is an engine of Desired State Configuration. The Local Configuration Manager is responsible for enacting and parsing configurations which are sent to the node. It controls all the executions of the DSC configurations.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf