Previous Multi-Region Architecture with VNets Azure-Monitor-Guide Next

PowerShell DSC (Desired State Configuration) & CLI

PowerShell DSC and DSC CLI

PowerShell DSC and its CLI are powerful tools for declarative infrastructure management— ensuring systems can self-heal, stay compliant, and align with architectural baselines.

⚙️ What Is PowerShell DSC?

DSC is a declarative configuration platform that defines the desired state of a system (e.g., installed features, file contents, registry settings) and enforces it automatically.

🔑 Key Concepts

  • Configuration Document: Written in PowerShell or YAML/JSON, describes what the system should look like.
  • DSC Resources: Modules that manage components (e.g., WindowsFeature, File, Registry).
  • Idempotency: Running the same config multiple times yields the same result without side effects.

🧠 How DSC Works

Author Configuration Example:

Configuration WebServerSetup {
  Node "localhost" {
    WindowsFeature IIS {
      Ensure = "Present"
      Name   = "Web-Server"
    }
  }
}
WebServerSetup
  
  • Compile to MOF File: Generates a .mof file describing the desired state.
  • Apply Configuration: Use Start-DscConfiguration to enforce the state.

🧩 PowerShell DSC Architecture Flow

Author Configuration PowerShell / YAML / JSON Compile to MOF DSC Engine / CLI Apply Configuration Start-DscConfiguration / dsc config set Node VM / Server

🖥️ CLI Interface (DSC v3)

The newer DSC CLI (dsc) is cross-platform, built on a Rust-based engine. It supports JSON/YAML configurations and adapter resources for PowerShell and Windows.

Example Commands:

dsc config set -f config.yaml
dsc resource list
dsc resource invoke --name File --method Set
  

🧩 Use Cases for You

Scenario DSC Benefit
Multi-tenant SaaS baseline enforcement Declarative config per tenant
Training VMs for interview modules Auto-provisioned environments
Static site deployment Ensures IIS, file structure, registry keys
Compliance-heavy workloads Enforces security policies and standards

🔄 CLI vs PowerShell DSC

Feature PowerShell DSC DSC CLI (v3)
Platform Dependency Windows PowerShell Cross-platform (Windows, Linux, macOS)
Language Support PowerShell scripts JSON/YAML + PowerShell adapter
Execution Engine WMF-based Rust-based, modular
Resource Invocation Cmdlets (Start-DscConfiguration) CLI commands (dsc config set)
Extensibility PowerShell modules Adapter-based (PowerShell, WMI, native)
Use Case Fit Windows server provisioning Cloud-native, containerized workloads
Idempotency ✅ Yes ✅ Yes
Logging & Diagnostics Verbose output, Event Viewer CLI logs, structured output
Back to Index
Previous Multi-Region Architecture with VNets Azure-Monitor-Guide Next
*