Skip to main content

Getting started with DSC 3.0 – Part 1: What is DSC and what changed?

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, set and export

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/Include resource 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!

More information

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cache stampede: when our cache turned against us

While investigating some performance issues, we ran into an ASP.NET Core API that cached a fairly expensive aggregation query for 60 seconds. Under normal load, that was fine: one request rebuilds the cache, everyone else reads from it. Under peak load, dozens of requests would arrive in that same expiry window, all see a cache miss, and all fire the same expensive query in parallel. The database didn't like that. That was the moment when our caching layer stopped helping and started hurting. A burst of requests comes in at the same time, all miss the cache, and all go hammer the database or the downstream API at once. That's a cache stampede . The cache was supposed to protect our backend, and for a few hundred milliseconds it did the opposite. Why this happens IMemoryCache.GetOrCreate (and its async sibling) looks like it protects you, but it doesn't add any locking on its own. Look at the naive version: public async Task<Report> GetReportAsync(string key) ...

VS Code Planning mode

After the introduction of Plan mode in Visual Studio , it now also found its way into VS Code. Planning mode, or as I like to call it 'Hannibal mode', extends GitHub Copilot's Agent Mode capabilities to handle larger, multi-step coding tasks with a structured approach. Instead of jumping straight into code generation, Planning mode creates a detailed execution plan. If you want more details, have a look at my previous post . Putting plan mode into action VS Code takes a different approach compared to Visual Studio when using plan mode. Instead of a configuration setting that you can activate but have limited control over, planning is available as a separate chat mode/agent: I like this approach better than how Visual Studio does it as you have explicit control when plan mode is activated. Instead of immediately diving into execution, the plan agent creates a plan and asks some follow up questions: You can further edit the plan by clicking on ‘Open in Editor’: ...