PowerShell Desired State Configuration (DSC) — Getting Started Guide (2026)

PowerShell Desired State Configuration (DSC) allows you to define the desired state of Windows machines declaratively and enforce that state automatically. This guide covers the basics of PowerShell DSC in 2026 — how to write configurations, apply them and use them for enterprise compliance enforcement.

What is PowerShell DSC?

DSC is a PowerShell platform that allows you to define how a machine should be configured — which Windows features should be enabled, which services should be running, which files should exist and which registry keys should be set. DSC then enforces that configuration, automatically correcting any drift from the desired state.

Your First DSC Configuration

# Simple DSC configuration - ensure IIS is installed and running
Configuration WebServerConfig {
    Import-DscResource -ModuleName PSDesiredStateConfiguration
    
    Node "WebServer01" {
        # Ensure IIS is installed
        WindowsFeature IIS {
            Name   = "Web-Server"
            Ensure = "Present"
        }
        
        # Ensure the World Wide Web Publishing Service is running
        Service W3SVC {
            Name        = "W3SVC"
            StartupType = "Automatic"
            State       = "Running"
            DependsOn   = "[WindowsFeature]IIS"
        }
        
        # Ensure a specific file exists
        File DefaultPage {
            DestinationPath = "C:\inetpub\wwwroot\index.html"
            Contents        = "

Welcome to our web server

" Ensure = "Present" } } } # Generate the MOF file WebServerConfig -OutputPath "C:\DSC\WebServer\Config"

Apply a DSC Configuration

# Apply configuration to local machine
Start-DscConfiguration -Path "C:\DSC\WebServer\Config" -Wait -Verbose -Force

# Apply to a remote machine
Start-DscConfiguration -Path "C:\DSC\WebServer\Config" -ComputerName "WebServer01" -Wait -Verbose -Credential (Get-Credential)

Check DSC Configuration Status

# Check if current state matches desired state
Test-DscConfiguration -Verbose

# Get detailed DSC status
Get-DscConfiguration

# Get DSC configuration status with details
Get-DscConfigurationStatus | Select-Object Status, StartDate, Type, Mode, RebootRequested

Common DSC Resources

ResourcePurpose
WindowsFeatureInstall or remove Windows roles and features
ServiceManage Windows services
FileManage files and directories
RegistryManage registry keys and values
UserManage local user accounts
GroupManage local groups
PackageInstall or uninstall software packages
ScriptRun PowerShell scripts as part of configuration

Configure LCM for Automatic Correction

# Configure Local Configuration Manager to auto-correct drift
[DscLocalConfigurationManager()]
Configuration LCMConfig {
    Node localhost {
        Settings {
            ConfigurationMode              = "ApplyAndAutoCorrect"
            ConfigurationModeFrequencyMins = 30
            RebootNodeIfNeeded             = $false
            RefreshMode                    = "Push"
        }
    }
}

LCMConfig -OutputPath "C:\DSC\LCM\Config"
Set-DscLocalConfigurationManager -Path "C:\DSC\LCM\Config" -Verbose

Frequently Asked Questions

What is the difference between DSC Push and Pull mode?

In Push mode you manually push configurations to target nodes using Start-DscConfiguration. In Pull mode target nodes periodically check a central pull server for their configuration and apply it automatically. Pull mode is better for large environments as it scales without requiring you to push to each machine individually.

Is PowerShell DSC still relevant in 2026?

Yes — DSC remains a powerful tool for Windows configuration management, particularly in environments that are not fully in Azure. Azure Policy and Azure Automation State Configuration (which uses DSC under the hood) are the cloud-native evolution. For on-premises environments DSC with SCCM or a pull server is still widely used.

How do I install additional DSC resources?

Install additional DSC resources from the PowerShell Gallery: Install-Module -Name xWebAdministration for IIS management, Install-Module -Name NetworkingDsc for network configuration, Install-Module -Name ComputerManagementDsc for computer management tasks. Run Find-Module -Tag DSC to browse available resources.

Can DSC manage non-Windows systems?

Yes — PowerShell DSC is available for Linux via the OMI (Open Management Infrastructure) provider. However the resource ecosystem for Linux is much smaller than Windows. For cross-platform configuration management, tools like Ansible or Chef are more commonly used alongside or instead of DSC on Linux.

About The Author


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Leave a comment