https://blogs.technet.microsoft.com/heyscriptingguy/2014/10/16/use-powershell-and-dsc-to-enable-logging/ You can also enable Debug and Analytic logs in Windows Event Logging. https://blogs.msdn.microsoft.com/powershell/2014/01/03/using-event-logs-to-diagnose-errors-in-desired-state-configuration/
E.g. if you want to reapply a DSC resource
rm C:\windows\system32\Configuration\*.mof*
gps wmi* | ? {$_.modules.ModuleName -like "*DSC*"} | stop-process -force
Note: you need a DSC Module for this: https://github.com/PowerShell/xDscDiagnostics
Install it Install-Module -Name xDscDiagnostics
, then import it into your session as Import-Module -Name xDscDiagnostics
.
Get the tasks that failed:
PS > Get-xDscOperation
ComputerName SequenceId TimeCreated Result JobID AllEvents
------------ ---------- ----------- ------ ----- ---------
VVAAPOCDB2 1 6/13/2018 7:13:43 AM Failure ff0a92a6-6ed8-11e8-a94a-000d3ab266f4 {@{Message=Deletin...
VVAAPOCDB2 2 6/13/2018 5:57:06 AM Failure 99ac233d-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
VVAAPOCDB2 3 6/13/2018 5:57:11 AM Success 99ac233e-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
VVAAPOCDB2 4 6/13/2018 5:57:15 AM Success 99ac233f-6ece-11e8-a94a-000d3ab266f4 {@{Message=Getting...
Use its JobID
to trace it.
Trace-xDscOperation -JobId ff0a92a6-6ed8-11e8-a94a-000d3ab266f4
Ref: https://stackoverflow.com/questions/37177678/desired-state-configuration-verbose-logging
C:\Windows\System32\Configuration\ConfigurationStatus
- Outputs are stored in JSON files.
- The relevant filename contains the
JobID
of the failed job.
Read the output with more
E.g. more "C:\Windows\System32\Configuration\ConfigurationStatus\{FF0A92A6-6ED8-11E8-A94A-000D3AB266F4}-0.details.json"
{"time": "2018-06-13T07:11:35.492+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changing the SQL system database default log path to 'L:\\LOGS' ..."},
{"time": "2018-06-13T07:11:35.492+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changing the SQL system database default file path to 'F:\\DATA' ..."},
{"time": "2018-06-13T07:11:35.555+00:00", "type": "error", "message": "F:\\DATA: The system cannot find the file specified."},
{"time": "2018-06-13T07:11:35.586+00:00", "type": "error", "message": "L:\\LOGS: The system cannot find the file specified."},
{"time": "2018-06-13T07:11:38.935+00:00", "type": "verbose", "message": "[VVSPPOCDB2]: [[xSqlServer]DirectResourceAccess] Changed database context to 'master'."},
{"time": "2018-06-13T07:11:38.950+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\tempdb.mdf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:38.950+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\templog.ldf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\model.mdf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\modellog.ldf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:38.966+00:00", "type": "error", "message": "The path specified by \"F:\\DATA\\msdbdata.mdf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:38.982+00:00", "type": "error", "message": "The path specified by \"L:\\LOGS\\msdblog.ldf\" is not in a valid directory."},
{"time": "2018-06-13T07:11:40.138+00:00", "type": "error", "message": "Exception setting \"StartupParameters\": \"STARTUPPARAMETERS: unknown property.\""},