liveBook · Manning

Desired State Configuration

As explained in 100 SQL Server Mistakes and How to Avoid Them

PowerShell Desired State Configuration is Microsoft's declarative configuration-management framework for defining and enforcing system states.

Mistake: treating a SQL Server installation script as sufficient. Scripts create consistency at build time, but later changes can introduce configuration drift. Desired State Configuration (DSC) describes the state a server should maintain and periodically evaluates whether reality still matches it. section 8.11 section 8.9

A DSC resource manages one configuration area, such as a registry key, folder, or software installation. Its test method checks the current state; its set method corrects the state when drift is found. A manifest combines resources and supplies their desired values. section 8.9

Disabling xp_cmdshell across SQL Server instances

A single DSC configuration can target multiple SQL Server hosts. During each evaluation, the test function checks whether xp_cmdshell is disabled. A compliant instance is left alone; an instance with the feature enabled receives the set action. With evaluation every 30 minutes, a misconfiguration is automatically corrected within zero to 30 minutes. section 8.9

The safer practice is to manage SQL Server for its full application lifecycle, not only its initial build. Configuration management reduces administrative overhead, supports security compliance, and helps prevent a server estate from silently diverging. section 8.11

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains resources, test and set methods, manifests, compilation, application, and periodic drift correction.
Examples
Uses xp_cmdshell enforcement, SqlSetup and SqlConfiguration resources, and PowerShell commands for module installation and deployment.
What you can do after
Apply DSC configurations that install SQL Server and automatically correct selected configuration drift.
How it connects
Connects configuration management with SQL Server installation, configuration drift, security compliance, Puppet, and Ansible.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.