Get-UcsFault One-Liner

Version 2

    UCS Communities Login ID: Joshua.Barton

    Have you read the Official Rules of the Contest and do you accept the terms and conditions     Yes  [ x ]    No  [   ]

    Are you a Cisco employee                                                                                                                          Yes  [  ]    No  [ x ]

    Does the script run on an emulator -                                                                                                          Yes [   ]    No  [  ]

              If yes which version? _______________

     

    Ran in a version 2.1(1a) UCS System (Not Emulator)

     

    Include your script here:

     

    # Script is wrapped in the body statement of Send-MailMessage.

    # Gathers all uncleared faults, sorts them by severity, convert the output to

    # HTML and use Out-String to make Send-MailMessage happy.

    # Update: Added formatting to increase legibility.

     

    Send-MailMessage -From "sender@domain.org" -To "recipient@domain.org" -Subject "UCS Faults" -SmtpServer "smtp.domain.org" -BodyAsHtml -Body (Get-UcsFault | Where { $_.Severity -ne "cleared" } | Select-Object Dn, Severity, Descr, Created | Sort Severity -Descending | ConvertTo-HTML -Head "<style type='text/css'>BODY{background-color:#f0f0f0;}TH,TD{border-width: 1px;padding: 10px;border-style: solid;border-color: black;border-collapse: collapse;}</style>" | Out-String)