Code Monkey home page Code Monkey logo

xdscdiagnostics's Introduction

Build status

xDscDiagnostics

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.

Contributing

Please check out common DSC Resources contributing guidelines.

Description

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.

Cmdlets

Get-xDscOperation

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

Trace-xDscOperation

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.

Update-xDscEventLogStatus

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.

Versions

2.0.0.0

  • Release with bug fixes and the following cmdlets
    • Get-xDscOperation
    • Trace-xDscOperation
    • Update-xDscEventLogStatus

1.0.0.0

  • Initial release with the following cmdlets
    • Get-xDscOperation
    • Trace-xDscOperation

Examples

Display the status of last 20 DSC operations

This example will list the last 20 DSC operations to see if any of them failed.

Get-xDscOperation -Newest 20

Display the status of the last two DSC operations in computer XXYY after passing Credential $cred

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

Trace a DSC operation that has a specific job ID

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

Get events of the second to last operation run on the localhost machine

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

Get diagnostic events of operations run on multiple computers that use the same credential

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

Enable the DSC Analytic event log

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

xdscdiagnostics's People

Contributors

karolkaczmarek avatar joeyaiello avatar powershellteam avatar

Watchers

James Cloos avatar Travis Plunk avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.