Display the most recent error messages in the system logs

Display the most recent error messages in the system logs

Administrators often have to stifle through Windows logs to troubleshoot problems with their systems or applications. However, manually going through heaps of system log information is laborious. The following PowerShell script, when executed, will return the most recent error messages within a specific number of logs. 


Script
<#
.SYNOPSIS
This script can be used to display the error messages in the most recent x number of logs.
.DESCRIPTION
This script can be used to display the error messages in the most recent x number of logs.
.EXAMPLE
C:\PS> C:\Script\System_Error_Logs.ps1 100
Displays the Error messages in most recent 100 logs.
#>

param ( [int]$count )
#Gets the newest x number of event logs.

$Event = Get-Eventlog -Logname system -Newest $count
#Filters errorlogs in the newest x number of event logs.

$Error = $Event | Where {$_.entryType -Match “Error”}
$Error | Sort-Object EventID |Format-Table EventID,Source,TimeWritten,Message -auto














    Limited-period offers on our IAM solutions




      • Related Articles

      • Display Events with a particular Text

        Administrators often have to stifle through Windows logs to troubleshoot problems with their systems or applications. However, manually going through heaps of system log information to find out the root cause of an event can be quite laborious.   ...
      • Display the Parent Process of a given Process

        The Get-Process command in PowerShell is a well-known cmdlet to return basic process information. However, what it does not return is the parent process of a particular process. With the following script, one can find out the parent process of a ...
      • Display maximum and minimum FreeSpace in a logical disk

        It is paramount for IT admins to check the available disk space in a particular system before pushing out an update or installing an application. However, to do so at scale can be intimidating, as it can quickly get out of hand.   With the following ...
      • Managing Microsoft updates on Windows

        System update management for Windows machines in an Active Directory (AD) environment is a critical task of an administrator. While managing the updates for a handful of machines is a fairly simple task, managing a many Windows machines and keeping ...
      • Get Screen Resolution of remote computers

        Administrators sometimes have to document certain properties of the computers in their network. The most common one is the screen resolution. Doing so on a collection of remote computers only adds to the complication. However, with the help of the ...