Skip to main content

Gets the 10 most recent SYSTEM and APPLICATION errors from the Windows Event Viewer logs and outputs them into the Automox Activity Monitor

Evaluation Code

exit 1

Remediation Code

### Gets the 10 most recent SYSTEM errors from the event viewer logs

Write-Host "10 Most Recent SYSTEM Log Errors"

$A = Get-EventLog -LogName System -EntryType Error -Newest 10

Foreach ($B in $A){
    "`---"
    $B | Select-Object -Property TimeGenerated, EventID, EntryType, Message, Source
}


### Gets the 10 most recent APPLICATION errors from the event viewer logs
"`---" 
Write-Host "10 Most Recent APPLICATION Log Errors"
"` "
$A = Get-EventLog -LogName Application -EntryType Error -Newest 10

Foreach ($B in $A){
    "`---" 
    $B | Select-Object -Property TimeGenerated, EventID, EntryType, Message, Source
}

From there you can read in the activity monitor, or copy and paste into a text editor and

find:
---

replace with:
---

To get a cleaner view.

Be the first to reply!