FeaturedPower ShellScripts

Get-EventLog Reports

   Get Event Log reports in HTML FOrmat
   This script design to get the report of any type of EventViewer log and display the report in HTML format.
   get-log -Computername localhost -log system -newest 1000 -path c:\report.html


function get-log {


    param (
     [string]$log = "system",
     [string]$Computername = $env:computername,
     [int32]$Newest = 500,
     [String]$ReportTitle = "Event Log Report",


    #get event log data and group it
    $data = Get-EventLog system -EntryType Error -Newest $Newest -ComputerName $Computername |
    Group-Object -Property Source -NoElement

    #Create HTML Report
    $footer = "<h5><i>report run $(get-date)</i></h5>"
    $css = "c:\design.css"
    $precontent = "<h1>$Computername</h1><h2> Last $newest error sources from $log </h2>"

    $data | Sort-Object -Property count, name -Descending |
        Select-Object Count, Name |
        ConvertTo-Html -Title $ReportTitle -PreContent $precontent -PostContent $footer -CssUri $css |
        Out-File -FilePath $path |



Show More

Related Articles

Back to top button