PowerShell Desired State Configuration: configure the Local Configuration Manager

Note to myself: when you try to configure a system using DSC, do not forget to configure the Local Configuration Manager first!

Today I caught myself in “troubleshooting” an issue with Desired State Configuration. The issue looked like that

  • when I tried to apply a new DSC Configuration, it was applied fine.
  • if I changed the systems configuration later, the change was caught by DSC and if I ran the get-DSCConfiguration cmdlet the configuration issue was shown in the resultset properly

But the system did notĀ get reconfigured by the set-procedure.

If you everĀ notice an issue like that, check your event logs first! You may take a note of your Event ID 4257 entries in your “Microsoft-Windows-Desired State Configuration/Operational” Event Log and check the ConfigurationMode setting.By default this is set to “ApplyAndMonitor” (see also https://msdn.microsoft.com/en-us/powershell/dsc/metaconfig). This will apply your configuration once and monitor for changes, but it will not re-apply your configuration! Unfortunately, this is true as well for machines deployed in Microsoft Azure.

What you really need when using DSC is the setting to apply, monitor and reconfigure. You can easily achieve that by a simple configuration to the LCM, like that

Once you ran this configuration by using the set-dscLocalConfigurationManager cmdlet, you will find your configuration applied. DSC now will run the set Scripts when your test scripts return “false”.