Description

The following powershell script retireves all error messages from event viewer about sql server instances installed on your local machine and export as an html file with a simple CSS so we could use the output as a web page or alternatively you could export output in csv format to open the output file in excel by using ConvertTo-Csv command.

Script

PowerShell
Edit|Remove
$style = "<" + "style>"  
$style = $style + "TABLE{border:1px solid black; border-collapse: collapse;}" 
$style = $style + "TH{border:1px solid black;background-color:black;color:white;}" 
$style = $style + "TD{border:1px solid black;}" 
$style = $style + "</" + "style>" 
$logs = Get-EventLog Application | where {$_.Source -like "MSSQL*"$logs = $logs | where {$_.EntryType -eq "Error"$logs = $logs | Select-Object EventId,Message,Source,TimeGenerated 
$logs | ConvertTo-Html -head $style | Out-File "c:\logs.html"
 

Note : i split style tags because of the code viewer :)