Foreword by Steve Lee
Foreword by Jason Helmick
Preface
- Who is this book for?
- Code listings and typographic conventions
- What you need for this book
- Feedback
- Published book version information
- About the author
Introduction
- The manual configuration era
- The rise of configuration management
- Enter PowerShell DSC
- Microsoft DSC: a new foundation
- Why Microsoft DSC?
- DevOps and configuration management
- Other resources
Chapter 1 - Getting Started with Microsoft Desired State Configuration
- From Windows PowerShell to command-line utility
- Configuration as data
- Installing Microsoft Desired State Configuration
- Manual installation
- Using PowerShell
- Using WinGet (Windows)
- Setting up your development environment
- Installing Visual Studio Code
- Configuring schema validation
- Enabling (tab)-shell completions
- Running your first commands
- Using a resource directly
- Creating your first configuration document
- Understanding get, set, and test operations
- Exploring resource schemas
- Finding help with resources and commands
- Built-in help
- Official documentation
- Summary
Chapter 2 - Understanding Microsoft Desired State Configuration
- A new foundation for the next generation of DSC
- When PowerShell DSC met Microsoft DSC
- From scripts to documents: rethinking how we write configurations
- Redefining what a DSC resource is
- Bridging worlds: PowerShell DSC resources in Microsoft DSC
- Working with the DSC command-line interface
- Understanding DSC output formats
- Logging and troubleshooting using trace levels
- Monitoring progress with progress formats
- Summary
Chapter 3 - DSC Configuration Documents
- The belly of the beast
- Working with the dsc config command
- Real-world examples
- Example 1: Windows development workstation
- Example 2: Setup fresh SQL Server 2025
- Summary
Chapter 4 - Inside Configuration Documents
- Peeling back the layers
- The schema: your contract with DSC
- Providing runtime flexibility with parameters
- Defining reusable variables
- Building the working units
- Declaring dependencies
- Directives and context
- Functions and expressions
- Validation and debugging
- Summary
Chapter 5 - Built-in Resources
- The toolbox that ships with DSC
- How resources get packaged
- Cross-platform resources
- Microsoft/OSInfo
- Microsoft.DSC.Debug/Echo
- Microsoft.DSC.Transitional/RunCommandOnSet
- Microsoft/Process
- Microsoft.OpenSSH.SSHD/sshd_config
- Windows-specific resources
- Microsoft.Windows/Registry
- Microsoft.Windows/UpdateList
- Microsoft.Windows/RebootPending
- Microsoft.OpenSSH.SSHD/Windows
- Linux-specific resources
- DSC.PackageManagement/Apt
- macOS-specific resources
- DSC.PackageManagement/Brew
- Meta resources
- Microsoft.DSC/Group
- Microsoft.DSC/Assertion
- Microsoft.DSC/Include
- Summary
Chapter 6 - PowerShell adapters
- The translation layer
- From one process to many: the adapter evolution
- Anatomy of the adapter manifests
- Inside the adapter script
- Entry point and parameter handling
- Trace logging
- Environment detection and setup
- Module path customization
- The List operation
- The cache and performance
- The helper modules
- Summary
Chapter 7 - Extensions
- When configuration alone isn’t enough
- Three kinds of building blocks
- What extensions can do: three capabilities
- Discover: finding resources
- Secret: retrieving sensitive values
- Import: translating configuration formats
- The extension manifest
- Building secret extensions
- The Azure Key Vault extension
- Windows Credential Manager extension
- Building a discovery extension: PowerShell module resources
- The discovery script and manifest
- Schema for class-based DSC resources
- PowerShell as first-class citizen to Microsoft DSC
- Building an import extension: MOF to DSC
- The import extension manifest
- The wrapper script
- Testing the import extension
- Summary
Chapter 8 - Advanced Patterns
- Going beyond the basics
- Resource capabilities: teaching DSC what your resource can do
- implementsPretest: “I’ll check before I act”
- handlesExist: “I know how to create and delete”
- Building a Windows scheduled task resource
- Assertions and conditions: validate before you act
- How assertions and conditions work
- Conditional execution
- The if function
- Combining conditions
- Including external configurations
- File-based includes
- Parameterized includes
- Building a configuration library
- PowerShell adapter credential support
- Faster discovery for PowerShell resources using adapted resource manifests
- Anatomy of an adapted resource manifest
- How DSC sends the path to the adapter
- Creating your own adapted resource manifest
- Adapted resources in manifest lists
- The fast path under the hood
- When and when not to use adapted resource manifests
- Re-discovery of resources during deployment
- How it works under the hood
- A practical example: bootstrapping a dev environment
- Performance trade-offs
- Comparison with assertions
- Previewing changes with what-if
- How DSC handles what-if mode
- Declaring native what-if support
- Controlling return types with
whatIfReturns - A real example: the Windows Registry resource
- Implementing what-if in your own resource
- The Bicep DSC extension: authoring DSC with Bicep
- Bicep as a higher-order tool
- What is bicep-types-dsc?
- Authoring a configuration in Bicep
- Running a configuration with local deploy
- Summary
Chapter 9 - Integration
- WinGet as higher-order tool
- How WinGet hooks into
dsc.exe - The WinGet configuration format
- A graphical user interface above the configuration engine
- How the GUI splits the work
- Two tools, one authoring loop
- OpenDSC: the missing enforcement layer
- The enforcement engine
- Local and pull operation
- The server and its GUI
- Getting started with OpenDSC
- Summary
Chapter 10 - Building your own DSC resource
- From consumer to creator
- Choosing a language
- The architecture: how a DSC resource CLI works
- The command flow
- Self-registration with
init() - Defining the resource interface
- Schema generation: teaching DSC about your properties
- Schema overrides for special cases
- Supporting lookup pattern for different inputs
- When to omit test: letting DSC do the comparison
- Manifest generation: making the build your source of truth
- The bridge between your API and DSC
- Logging to the DSC engine
- Testing strategy: integration tests against the real API
- Summary
Closing thoughts
Appendix: A note on schema canonicalization
- Two descriptions of the same contract
- Why this matters
- Where DSC is heading
- What changes for a resource author
- Why this belongs in an appendix
- A final note