Skip to content

ADR-0004 — Use PowerShell DSC for Windows Configuration Management

Status

Accepted

Context

The deterministic documentation pipeline covers Linux-centric infrastructure via Terraform and Ansible. Many enterprise environments also include Windows-based workloads managed through PowerShell Desired State Configuration (DSC).

Key challenges:

  1. Documentation consistency — DSC configurations are written in PowerShell. Without tooling, documentation is written manually and drifts from the implementation.
  2. Testability — DSC resources are complex stateful objects that benefit from automated unit testing before deployment.
  3. Cross-platform portability — Class-based DSC resources written for PowerShell Core 7+ can be developed and tested on Linux (including in CI) even when the target nodes are Windows.

Decision

We will adopt the following toolchain for the DSC layer of the stack:

Tool Purpose
Class-based DSC resources (PowerShell Core 7.2+) Express desired state in typed, testable classes
DscResource.DocGenerator Auto-generate Markdown documentation from resource classes and comment-based help
PlatyPS Underlying Markdown generation used by DscResource.DocGenerator
Pester 5 Unit-test Get/Test/Set methods of each resource class

DSC resources will be placed in dsc/resources/<ModuleName>/ and follow the standard PowerShell module structure (.psm1 + .psd1). Documentation will be generated by dsc/build.ps1 into docs/generated/dsc-resources/.

Consequences

Positive

  • Documentation is generated from the authoritative source (the .psm1 class) — it cannot drift.
  • Pester tests validate the idempotency contract (Test/Set/Test) before any configuration is applied to nodes.
  • Class-based resources work on PowerShell Core 7+ on Linux, so the existing Linux CI runners can test them without a Windows runner.
  • DscResource.DocGenerator integrates cleanly with the MkDocs site via Markdown output.

Negative / Trade-offs

  • MOF compilation and LCM application still require a Windows node; the example uses pwsh -File DscConfiguration.ps1 which runs cross-platform for compilation only.
  • DscResource.DocGenerator is a community module (DSC Community) rather than a Microsoft-supported product; it may lag behind PowerShell releases.
  • Adding PowerShell to the Docker toolchain image increases the image size.

Alternatives Considered

Alternative Rejected Because
Chef / Puppet Significant operational overhead and different module ecosystem
Ansible win_* modules Covered by ADR-0001's Ansible decision; DSC provides a Windows-native pattern for enterprises already using DSC
Hand-written Windows docs Violates the core principle — documentation must be generated from source