How to setup Debug Mode in Windows PowerShell Desired State Configuration (DSC)

If you work on custom DSC resources then debug mode is very handy for you because you may need to re-import your updated DSC resource again and again. Without re-import (force import) the DSC uses cache.

How to set DebugMode:

  • None
    • Signifies that DebugMode is False and not applicable.
  • ForceModuleImport
    • Enforce the resource module to be reloaded instead of using the cache. This is similar to “true” value in previous versions.
  • ResourceScriptBrealAll
    • Helps in debugging DSC resources when Local configuration manager tries to execute their functions. More on it in subsequent blog posts!
  • All
    • Signifies that debugging as well as reloading of modules are both enabled.
Configuration LCMDebugMode {
    Node localhost {
        Settings {
            ConfigurationMode    = 'ApplyOnly'
            RefreshMode          = 'Push'
            Debugmode            = 'ForceModuleImport'

LCMDebugMode -OutputPath $directoryPath
Set-DscLocalConfigurationManager -Path $directoryPath -Verbose

The second option to mitigate cache is to restart service but this is not recommended procedure:

Restart-Service -Name winmgmt -Force -Verbose

Leave a Reply

Your email address will not be published. Required fields are marked *

Active Directory Advanced function AlwaysOn Availability Groups AlwaysOn Failover Cluster Instances Building Cloud Cloud Cluster Cmdlet Database Deployment Design DFS Domain Controller DSC Fabric Failover Clustering File Server Group Policy Hardware Profile Host Hyper-V Installation Library Library Asset Library Server Network Operations Manager Orchestrator PowerShell PowerShell User Group PowerShell Workflow Security Service Manager SQL Server Storage System Center Template Time Time Synchronization Tips Virtual Machine Virtual Machine Manager VM Network VM Template Windows Server 2012 R2