On this page

PowerShell DSC Declarative Configuration Guide

Updated on June 24, 2026

Enrico Hochkoeppler Profile

By Enrico Hochkoeppler

Web Developer & TutoriaLibre Founder

Declarative configuration is the core principle that makes PowerShell Desired State Configuration (DSC) predictable, scalable, and resilient in large environments. Unlike imperative scripts that specify how to configure a system through step-by-step instructions, DSC allows you to describe what the final state must be. The DSC engine—through the Local Configuration Manager (LCM) on each node—determines how to achieve and maintain that state. DSC configurations are idempotent, meaning they can be applied repeatedly without side effects, and the LCM continuously monitors for and corrects configuration drift. This fundamental shift from procedural automation to declarative configuration is what enables DSC to manage hundreds of machines consistently with minimal administrative overhead.


Declarative vs. Imperative Approaches​

To understand declarative configuration, it is useful to contrast it with the imperative model.

Imperative (Traditional Scripting)​

You write explicit steps:

The script must define the entire procedure. If something changes later—such as a service stopping—you must run the script again or write additional logic to detect and correct the issue.

Declarative (DSC)​

You describe the desired end state:

DSC determines how to enforce that state and continuously ensures the system remains compliant.

The key difference is that with declarative configuration, the definition of an application environment is separate from the programming logic that enforces that definition. The DSC command-line application abstracts the management of software components declaratively and idempotently.


How Declarative Configuration Works in DSC​

A DSC configuration is a Windows PowerShell script that defines a special type of function. The configuration uses a special syntax to declare the desired state of system components and does not contain procedural logic. Instead, it defines resources, each representing a part of the system.

Example of a Declarative Configuration​


Configuration WebServerConfig {

    Node "Server01" {



        WindowsFeature WebServer {

            Name   = "Web-Server"

            Ensure = "Present"

        }



        Service W3SVC {

            Name        = "W3SVC"

            State       = "Running"

            StartupType = "Automatic"

        }

    }

}

Explanation​

Notice that the configuration does not specify commands like Install-WindowsFeature or Start-Service. It simply declares the desired state.

In DSC 3.0, configuration documents are defined in JSON or YAML files rather than PowerShell script files. DSC supports writing configuration documents in both JSON and YAML, making them accessible even to readers who are not subject matter experts.


The Role of the Local Configuration Manager (LCM)​

The Local Configuration Manager (LCM) runs on every DSC-managed node. It is the engine by which DSC facilitates the interaction between resources and configurations.

The LCM:

If the system is out of state, the LCM calls the code in resources to apply the configuration according to what is specified. Because the configuration is declarative, the LCM can safely reapply it at any time.

Important: DSC 3.0 differs fundamentally from earlier versions—it does not include a Local Configuration Manager. Instead, DSC 3.0 is delivered as a set of PowerShell modules that act more like a declarative configuration framework, designed to integrate with external orchestrators such as Azure Policy, Azure Automation, or third-party configuration managers. DSC 3.0 is invoked as a command and does not run as a service.


Idempotence: A Key Benefit of Declarative Configuration​

Declarative resources in DSC are idempotent. Idempotence means that an operation has no additional effect if it is called more than once with the same input.

In practice:

For example, if a feature is already installed, DSC does nothing. If a service is already running, DSC does nothing. If a file already exists with the correct content, DSC does nothing.

The LCM will ensure that machines are configured in whatever state the configuration declares, regardless of how many times the configuration is applied. This makes DSC safe to run repeatedly across large environments.


Why Declarative Configuration Matters at Scale​

Declarative configuration is essential for environments where:

DSC helps eliminate configuration drift and ensures the state is maintained for compliance, security, and performance. Declarative models eliminate the complexity of procedural scripts and allow administrators to focus on defining the correct state rather than writing logic to achieve it.


Summary​

Declarative configuration is the foundation of DSC. It allows administrators to:

By shifting from "how to configure" to "what the configuration must be," DSC provides a powerful, reliable, and maintainable approach to managing systems at scale. As Microsoft's documentation states: "Unlike imperative tools, with DSC the definition of an application environment is separate from the programming logic that enforces that definition".

Found this helpful? Share the knowledge...

... or support this project to keep it alive!

Buy Me a Coffee

Previous

The Purpose of DSC

Next

Resources and Configurations