What I recommend to know about DSC resources

If you started to learn Microsoft's approach to Configuration as Code and found out what Desired State Configuration is, you probably tried to scrutinize PowerShell DSC resources code on GitHub in didn't get it.

For ones who need to know how it works and how to find out resource parameters, I recommend to read the following articles (in the order provided):

  1. Understanding CONFIGURATION keyword ... from PowerShell Team.
  2. Hungry for more Windows PowerShell Desired State Configuration Resources? from PowerShell Team.
  3. Anatomy of a PowerShell DSC Resource from Dr Scripto.

It helped me very much.

Now, imagine you found some DSC resource module, for instance cChoco (in PowerShell Gallery, on GitHub), and you need to know what properties its resources have. Super helpful may be command Get-DscResource, applied like:

(Get-DscResource cChocoPackageInstaller).Properties | Format-Table

.. which outputs something like:

Name                 PropertyType   IsMandatory Values
----                 ------------   ----------- ------
Name                 [string]              True {}
AutoUpgrade          [bool]               False {}
chocoParams          [string]             False {}
DependsOn            [string[]]           False {}
Ensure               [string]             False {Absent, Present}
Params               [string]             False {}
PsDscRunAsCredential [PSCredential]       False {}
Source               [string]             False {}
Version              [string]             False {}

It says, parameters Name, AutoUpgrade, chocoParams, DependsOn, Ensure, Params, PsDscRunAsCredential, Source, Version available to you if you build configuration like:

Configuration SSHServerFeature
    param (
    Import-DscResource -Module cChoco

    Node $NodeName
        cChocoInstaller installChoco
            InstallDir = "c:\choco"
        cChocoPackageInstaller ...
            Name                 = '...'
            Ensure               = 'Present'
            DependsOn            = "[cChocoInstaller]installChoco"
            AutoUpgrade          = $True

By the way, if you install OpenSSH server don't forget about Params with the value like '"/SSHServerFeature /KeyBasedAuthenticationFeature"', otherwise you get into the story as I got.