If you've worked with PowerShell DSC before, you probably remember writing a Configuration block, generating a MOF file and hoping the Local Configuration Manager did what you expected.
DSC 3.0 throws most of that away and provides a more modern incarnation of infrastructure-as-code.
Let me explain what it is, and what makes 3.0 different.
What is DSC?
Desired State Configuration is a declarative way to manage a system. You describe what the system should look like, not how to get there. DSC figures out the rest.
It is kind of the first incarnation of Infrastructure as Code.
Three concepts are enough to understand DSC:
- Configuration document: a file that describes the desired state
- Resource: the piece that knows how to read and change one specific thing (a registry key, a service, a package, ...)
- Operations: what you can do with a resource:
get,test,setandexport
So the question becomes: if the concepts stays the same, what changed in 3.0?
What is different in 3.0?
The naming is confusing, so let me make it explicit:
- PowerShell DSC 1.1 ships with Windows PowerShell 5.1
- PowerShell DSC 2.0 ships with PowerShell 7
- Microsoft DSC 3.0 is a separate, standalone product
DSC 3.0 is not "the next PowerShell module", it is a completely new product.
As it really is something new, a lot has changed (except the name) between versions:
- No dependency on PowerShell. You can run DSC without PowerShell installed and write resources in bash, Python, C#, Go or whatever you prefer.
- No Local Configuration Manager. DSC 3.0 doesn't include or support the LCM. DSC runs when you (or an orchestrator) call it.
- JSON or YAML instead of MOF and PowerShell scripts. Configuration documents are plain data. Resource schemas are described in JSON, not MOF.
- Runtime parameters. You can pass parameter values as JSON or point to a parameters file. No more generating a MOF per environment.
- Cross-platform. Windows, Linux and macOS.
- New resource kinds. Groups change how a list of resources is processed. Importers pull in a configuration from somewhere else. The built-in
Microsoft.DSC/Includeresource is an example.
Remark: DSC 3.0 also has no built-in orchestration. Tools like Azure Machine Configuration and WinGet are positioned as the orchestration agents on top of it.
I asked AI to put it into one overview:
What about my existing PowerShell DSC resources?
If you already were using previous DSC versions, this is certainly a question you have. The good news is that you can still use them. DSC 3.0 can invoke existing PowerShell DSC resources, both script-based and class-based, through the Microsoft.DSC/PowerShell adapter (and Microsoft.Windows/PowerShell for Windows PowerShell).
An adapter sits between the DSC engine and a resource and translates between the formats. That's how the old world keeps working inside the new one.
Important: your resources are compatible, your configuration documents are not. You'll need to rewrite those as YAML or JSON.
DSC in action
Install it on Windows through winget:
winget install --id Microsoft.DSC
Create a minimal configuration document, for example config.dsc.yaml:
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Operating system
type: Microsoft/OSInfo
properties: {}
And let's ask DSC for the current state (in an elevated command line):
dsc config get --file config.dsc.yaml
Nothing is changed here. get only reads. Replace get with test to check if the system matches your document or set to enforce it.
Want to see which resources you have available?
dsc resource list
There is a long list of available resources. A small fragment is visible in the screenshot below:
What's next?
In the next part we'll write a real configuration with parameters and apply it with set.
That's it for this Friday!
