The xDscDiagnostics module contains two cmdlets for analyzing DSC event logs and identifying the causes of any failure in a DSC operation: Get-xDscOperation and Trace-xDscOperation.
Please check out common DSC Resources contributing guidelines.
The xDscDiagnostics module exposes two primary functions--Get-xDscOperation and Trace-xDscOperation--and one helper function--Update-xDscEventLogStatus--that aid in diagnosing DSC errors. Here, we use the term DSC operation to indicate the execution of any DSC cmdlet from its start to its end. For instance, Start-DscConfiguration and Test-DscConfiguration would form two separate DSC operations. The cmdlets also let you diagnose operations run on other computers. More details about their usage is given below in the Details section.
This cmdlet lists statuses of the last few run DSC operations. It returns an object that has information about the time that operation was created, whether the operation was successful or not, a handle to all the events generated by that operation, and the unique job identifier for that operation. (Read this blog to understand the role of the job ID in DSC events.) The cmdlet accepts the following parameters:
- Newest: Number of past operations you want to output. By default, it will display details of the last 10 operations
- ComputerName: Name of the computer from which you'd like to collect the event diagnostic details.
The input can be an array of strings.
You would need to execute the command
New-NetFirewallRule -Name "Service RemoteAdmin" -Action Allow
on the remote computer in order to execute this operation on it. - Credential: Credentials required to access the computer given in the ComputerName property
Once we run Get-xDscOperation, we can see which of the operations were a failure/success. Also, we can note a correlation between SequenceID and JobID for each operation. Trace-xDscOperation takes either of these values as parameters and gives you a readable list of events generated by their respective DSC operation. By default, Trace-xDscOperation will list all the events generated by the most recent DSC operation. This cmdlet returns an object that contains properties such as event type, event message, and time of event creation. The cmdlet accepts the following parameters:
- SequenceID: This is a field present in the object returned from running Get-xDscOperation. It identifies an operation run in the computer. By specifying the sequence ID, all the events pertaining to the corresponding operation are returned.
- JobID: This is a GUID that is a prefix to all the events published by DSC, which uniquely identifies each operation. It is also a field present in the object returned from running Get-xDscOperation cmdlet. By specifying a JobID, this cmdlet will extract and display all events pertaining to the corresponding DSC operation.
- ComputerName: Name of the computer from which you'd like to collect the event diagnostic details.
The input can be an array of strings.
You would need to execute the command
New-NetFirewallRule -Name "Service RemoteAdmin" -Action Allow
on the remote computer(s) in order to execute this operations on it. - Credential: Credentials required to access the computer given in the ComputerName property.
This cmdlet helps us enable or disable any of the DSC event logs. When the cmdlets Get-xDscOperation and Set-xDscOperation are used, they will output details from events generated in the enabled channels. If the channel is disabled, a warning is issued on the PowerShell console. By using the cmdlet Update-xDscEventLogStatus, you could enable the channel required to collect DSC events.
- Channel: This is a mandatory parameter that indicates which DSC channel status needs to be updated: { Analytic | Debug | Operational }
- Status: This is a mandatory parameter that indicates the final state of the channel: { Enabled | Disabled }
- ComputerName: Name of the computer on which you would like to set the log status.
You would need to execute the command
New-NetFirewallRule -Name "Service RemoteAdmin" -Action Allow
on the remote computer(s) in order to execute this operations on it. - Credential: Credentials required to access the computer given in the ComputerName property.
- Release with bug fixes and the following cmdlets
- Get-xDscOperation
- Trace-xDscOperation
- Update-xDscEventLogStatus
- Initial release with the following cmdlets
- Get-xDscOperation
- Trace-xDscOperation
This example will list the last 20 DSC operations to see if any of them failed.
Get-xDscOperation -Newest 20
This example lets you find the status of DSC operations run on another computer. Note: this requires a credential.
Get-xDscOperation -ComputerName Temp-Computer.domain.com -Credential $cred -Newest 2
This example displays all events generated by the DSC operation that was assigned a particular unique job ID.
Trace-xDscOperation -JobId aa6b4f3e-53f9-4f02-a502-26028e7531ca
This example displays a list of events and their messages published by the DSC operation run second to last (i.e. the sequence ID assigned to it is 2).
Trace-xDscOperation -SequenceId 2 -ComputerName localhost
This example displays the list of events and their messages from multiple computers, as long as the credential passed works for all of them.
Get-xDscOperation -ComputerName localhost, tempcomputer.domain.com -Credential $cred
This example shows how you can enable the DSC Analytic channel event log. By default, this channel is disabled. By using this cmdlet, you can enable the channel collect all DSC events using the other 2 xDscDiagnostics cmdlets.
Update-xDscEventLogStatus -Channel Analytic -Status Enabled