- Courses
- đź’»Programming Languages
- 🪟PowerShell
- PowerShell Scripting at Scale
- Desired State Configuration (DSC)
- Resources and Configurations
On this page
PowerShell DSC Resources and Configurations Guide
Updated on June 24, 2026
By Enrico Hochkoeppler
Web Developer & TutoriaLibre Founder
DSC resources and configurations are the two fundamental building blocks of PowerShell Desired State Configuration. A resource is a component that knows how to manage a specific part of a system—such as a file, a service, or a Windows feature—and implements Get, Test, and Set operations to retrieve state, validate compliance, and enforce the desired state. A configuration is a declarative definition—traditionally a PowerShell script, though DSC v3 supports JSON and YAML—that uses resources to describe the desired state of one or more nodes. The Local Configuration Manager (LCM) applies and maintains that state, detecting and correcting configuration drift automatically. This separation of responsibilities makes DSC modular, extensible, and predictable for managing systems at scale.
What DSC Resources Are​
A DSC resource is a standardized interface for managing the settings of a system. Resources provide the building blocks for a DSC configuration. A resource exposes properties that can be configured (its schema) and contains the logic that the DSC engine calls to enforce the desired state.
Each resource defines:
- What it can control — for example, a file, a service, a Windows feature, or an environment variable
- How to check the current state
- How to bring the system into compliance
Resources can model components as generic as a file or as specific as an IIS server setting. Groups of like resources are combined into a DSC Module, which organizes all required files into a portable structure that includes metadata identifying how the resources are intended to be used.
Common Built‑in DSC Resources​
ResourcePurposeFileEnsures a file or directory exists with specific content or attributesServiceEnsures a Windows service is running, stopped, or disabledWindowsFeatureInstalls or removes Windows Server roles and featuresRegistryManages registry keys and valuesPackageInstalls software packages
Each resource exposes a set of properties that define the desired state. For example, the Service resource includes properties such as Name, State, and StartupType.
How Resources Work Internally​
Every DSC resource implements core operations that the DSC engine calls to manage state.
The Get, Test, and Set Operations​
The general operations for managing system state are Get, Test, and Set.
OperationPurposeGetReturns the actual state of a specific resource instance on the systemTestCompares the actual state to the desired state and indicates how they differSetEnforces the desired state of a resource instance on the system
DSC invokes the Get operation when you use dsc resource get or dsc config get. It invokes the Test operation when you use dsc resource test or dsc config test. It invokes the Set operation when you use dsc resource set or dsc config set.
Additional Operations in DSC v3​
DSC v3 introduces additional resource operations:
OperationPurposeDeleteRemoves a resource instance from a systemExportRetrieves the actual state for every instance of a resource and returns a configuration documentListRetrieves the available adapted resources for a specific DSC adapter resource
This structure allows DSC to detect configuration drift, apply changes only when needed, and reapply configurations safely and idempotently.
Resource Schema Definition​
Each resource has a schema that determines the syntax needed to use the resource in a configuration. A resource's schema can be defined in several ways:
- Schema.mof file: Most resources define their schema in a schema.mof file using Managed Object Format
- ResourceName.schema.psm1 file: Composite resources define their schema in a
.schema.psm1file using a parameter block - ResourceName.psm1 file: Class-based DSC resources define their schema in the class definition
In DSC v3, new resources define their schemas with JSON or YAML files, not MOF files. Self-contained resources define a resource manifest that indicates how DSC should invoke the resource and what properties the resource can manage.
What a DSC Configuration Is​
A DSC configuration is a declarative definition that uses DSC resources to describe the desired state of one or more nodes (machines). It is declarative, meaning it describes what the system should look like, not how to configure it.
A configuration:
- Defines target nodes
- Uses resources to describe the desired state
- Produces a MOF file (Managed Object Format) for each node (in DSC 1.x/2.x)
- Is applied by the Local Configuration Manager (LCM)
Example: A Simple DSC Configuration (PowerShell Script)​
Configuration WebServerConfig {
Node "Server01" {
WindowsFeature WebServer {
Name = "Web-Server"
Ensure = "Present"
}
Service W3SVC {
Name = "W3SVC"
State = "Running"
StartupType = "Automatic"
}
}
}
Code explanation: Configuration defines a DSC configuration block. Node specifies the target machine. WindowsFeature is a resource that manages Windows Server features—Ensure = "Present" declares that the feature must be installed. Service is a resource that manages Windows services—State = "Running" declares that the service must be running. This configuration does not contain procedural commands. It simply declares the desired state.
DSC Configuration Documents in DSC v3​
In DSC v3, configuration documents are defined in JSON or YAML files, not 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.
Example scenarios include defining requirements for an application environment or specifying operational and security standards.
Advanced Configuration Elements​
Within a Configuration block, you can use:
- Variables: Store values and make configurations more dynamic
- Parameters: Pass parameters to configurations to make them reusable across different environments
- Conditional logic: Use
if/elsestatements to apply configurations based on conditions - Loops: Apply configurations to multiple resources
Compiling and Applying the Configuration​
In DSC 1.x and 2.x, a configuration must be compiled into a MOF file before it can be applied.
Compiling the Configuration​
WebServerConfig
This command generates:
.\WebServerConfig\Server01.mof
The MOF file is what the LCM reads and enforces.
Applying the Configuration​
Start-DscConfiguration -Path .\WebServerConfig -Wait -Verbose
Code explanation: -Path specifies the folder containing the MOF file. -Wait keeps the console open until the configuration is applied. -Verbose shows detailed output. The LCM reads the MOF file and ensures the system matches the declared state.
DSC v3 Application Method​
In DSC v3, configurations are applied using the dsc config command. DSC is invoked as a command—it does not run as a service and does not include a Local Configuration Manager.
The Role of the Local Configuration Manager (LCM)​
The Local Configuration Manager (LCM) runs on the nodes or machines you wish to configure. 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 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. Because the configuration is declarative, the LCM can safely reapply it at any time. DSC configurations are idempotent: the LCM ensures that machines are configured in whatever state the configuration declares, regardless of how many times the configuration is applied.
Important: DSC 3.0 differs fundamentally from earlier versions—it does not include a Local Configuration Manager. DSC 3.0 is delivered as a set of command-line tools that act as a declarative configuration framework, designed to integrate with external orchestrators such as Azure Policy, Azure Automation, or third-party configuration managers.
How Resources and Configurations Work Together​
The relationship between resources and configurations is straightforward:
- Resources define what can be managed
- Configurations define how those resources should be configured
- The LCM enforces the configuration using the resource logic
This separation of responsibilities makes DSC modular, extensible, and predictable.
Resource Discovery​
You can use the dsc resource list command to enumerate the available DSC resources on a machine. DSC discovers resources by searching the folders in your PATH environment variable for files with suffixes like .dsc.resource.json, .dsc.resource.yaml, or .dsc.resource.yml.
To retrieve the syntax for a DSC resource, use the Get-DscResource cmdlet with the -Syntax parameter.
Extending DSC with Custom Resources​
If built-in resources are not enough, you can create custom resources.
Class-Based Resources (DSC v3)​
Class-based DSC resources offer a modern, object-oriented approach to configuration management. Benefits include:
- Broad compatibility: Works with both DSC v3 and legacy PSDSC engines
- Simplified authoring: Define schema and logic in a single class definition
- No separate schema files: Schema is defined in the class properties
Types of Custom Resources​
DSCv3 supports several kinds of resources:
- Command-based resources: Defined with a resource manifest that describes how to invoke the resource and validate properties
- Resource groups: Command-based resources with a
resourcesproperty that processes an array of resource instances - Resource providers: Enable the use of non-command-based resources with DSCv3, such as the
DSC/PowerShellGroupresource provider for PowerShell-based resources
Differences Between DSC v3 and PowerShell DSC (PSDSC)​
DSC v3 differs from PowerShell Desired State Configuration (PSDSC) in several important ways:
FeatureDSC v3PSDSC (Legacy)PowerShell dependencyDoes not depend on PowerShellRequires PowerShell or Windows PowerShellLocal Configuration ManagerNo LCM—invoked as a commandIncludes LCM that runs as a serviceConfiguration formatJSON or YAML filesPowerShell script filesResource schemaJSON or YAML filesMOF files or class definitionsResource languagesAny language (bash, Python, C#, Rust, etc.)PowerShell onlyCompatibilityFull compatibility with PSDSC resources through adapter resourcesNative PowerShell resources only
DSC v3 provides full compatibility with PSDSC resources through the Microsoft.DSC/PowerShell and Microsoft.Windows/WindowsPowerShell adapter resources.
Summary​
Resources and configurations are the foundation of DSC:
- Resources provide the building blocks for managing system components. Each resource implements Get, Test, and Set operations to retrieve state, validate compliance, and enforce the desired state.
- Configurations declare the desired state using those resources. Configurations are declarative—they describe what the system should look like, not how to configure it.
- The LCM applies and maintains that state in DSC 1.x and 2.x. In DSC v3, the command-line tool (
dsc) invokes configurations and resources directly.
This model enables scalable, repeatable, and reliable configuration management across large environments. Whether using legacy PowerShell DSC or the new cross-platform DSC v3, the principles remain the same: declare the desired state, let the engine enforce it, and eliminate configuration drift at scale.
Found this helpful? Share the knowledge...
... or support this project to keep it alive!
Previous
Declarative Configuration
Next
Applying and Monitoring Configurations
-
What DSC Resources Are
- Common Built‑in DSC Resources
-
How Resources Work Internally
- The Get, Test, and Set Operations
- Additional Operations in DSC v3
- Resource Schema Definition
-
What a DSC Configuration Is
- Example: A Simple DSC Configuration (PowerShell Script)
- DSC Configuration Documents in DSC v3
- Advanced Configuration Elements
-
Compiling and Applying the Configuration
- Compiling the Configuration
- Applying the Configuration
- DSC v3 Application Method
-
The Role of the Local Configuration Manager (LCM)
-
How Resources and Configurations Work Together
- Resource Discovery
-
Extending DSC with Custom Resources
- Class-Based Resources (DSC v3)
- Types of Custom Resources
-
Differences Between DSC v3 and PowerShell DSC (PSDSC)
-
Summary
