Searching event logs for specific events
Several times after discovering a problem, the first question asked is: How often has this occurred? If the problem is logged in the Windows event log, the answer to that question is only a matter of looking in the logs for the specific error.
However, this can also be problematic. If the event is logged on multiple systems, or in a busy event log, or has been occurring for a long time, searching for the error events can be difficult. Searching for a needle in a large haystack can be next to impossible.
In this recipe, we will cover multiple methods to query the Windows event log.
Getting started
For this recipe, we will be using a basic Windows Server 2012 system.
How to do it...
Complete the following steps to query the event log:
Show the recent events that have been recorded in a specific log.
Get-WinEvent -LogName System -MaxEvents 10
When executed, the last ten events will be displayed, as shown in the following screenshot:
Show the recent events from...