- Courses
- đź’»Programming Languages
- 🪟PowerShell
- PowerShell Scripting at Scale
- Desired State Configuration (DSC)
- Declarative Configuration
On this page
PowerShell DSC Declarative Configuration Guide
Updated on June 24, 2026
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:
- Install this feature
- Start this service
- Create this file
- Set this registry key
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:
- The feature must be installed
- The service must be running
- The file must exist
- The registry key must have this value
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​
Configurationdefines a DSC configuration blockNodespecifies the target machineWindowsFeatureis a DSC resource that manages Windows featuresEnsure = "Present"declares that the feature must be installedServiceis a resource that manages Windows servicesState = "Running"declares that the service must be running
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:
- Reads the configuration
- Determines what is already correct
- Applies changes only where needed
- Regularly polls the system using the control flow implemented by resources to maintain the state defined by a configuration
- Automatically corrects deviations
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:
- Applying the same configuration multiple times produces the same result
- No duplicate actions occur
- No harm is done by reapplying configurations
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:
- Many machines must be configured identically
- Configuration drift must be prevented
- Compliance must be enforced
- Systems must be rebuilt or replaced quickly
- Automation must be predictable and repeatable
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:
- Describe the desired state of a system
- Avoid writing procedural logic
- Rely on the LCM (in DSC 2.x) or external orchestrators (in DSC 3.0) to enforce and maintain compliance
- Achieve idempotent, predictable automation
- Scale configuration management across large environments
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!
Previous
The Purpose of DSC
Next
Resources and Configurations
-
Declarative vs. Imperative Approaches
- Imperative (Traditional Scripting)
- Declarative (DSC)
-
How Declarative Configuration Works in DSC
- Example of a Declarative Configuration
- Explanation
-
The Role of the Local Configuration Manager (LCM)
-
Idempotence: A Key Benefit of Declarative Configuration
-
Why Declarative Configuration Matters at Scale
-
Summary
