How to Use the Windows PowerShell ‘Get-EventLog’ Command for Advanced Troubleshooting

The Nightmare of the Event Viewer GUI

When a Windows server randomly reboots, an application silently crashes, or a user reports a mysterious “Blue Screen of Death,” the answer is almost always hidden inside the Windows Event Logs.

Historically, administrators have used the graphical Event Viewer (eventvwr.msc) to hunt for these clues. However, the Event Viewer is notoriously slow. Loading a massive “System” log can take minutes, and manually scrolling through 40,000 informational messages to find three critical errors is an agonizing process.

For modern Windows administration, you must abandon the GUI and use the powerful PowerShell cmdlet: Get-EventLog. This command allows you to filter, parse, and export event data instantly using the command line.

1. Basic Log Retrieval

To view the most recent entries in a specific log, open PowerShell as an Administrator. The two most important logs to check are usually System (hardware/driver issues) and Application (software crashes).

To pull the 20 most recent entries from the System log:

Get-EventLog -LogName System -Newest 20

2. Filtering for Errors (The Lifesaver)

You rarely care about “Information” events. You are usually looking for “Errors” or “Warnings.”

To tell PowerShell to scan the entire Application log but only output the severe errors, use the -EntryType parameter:

Get-EventLog -LogName Application -EntryType Error

This command instantly strips away the thousands of useless informational messages, leaving you with a clean, actionable list of software failures.

3. Time-Based Filtering

If a user complains that a server crashed “sometime yesterday afternoon,” you don’t need to load the log for the entire year.

You can use the -After and -Before parameters to slice out a specific time window.

Get-EventLog -LogName System -EntryType Error -After (Get-Date).AddDays(-2)

This specific command dynamically calculates the current date, subtracts two days, and outputs any System Errors that have occurred within the last 48 hours.

4. Searching for Specific Applications or Keywords

If you know exactly which application is failing (e.g., Microsoft SQL Server), you can filter by the “Source” of the event.

Get-EventLog -LogName Application -Source "MSSQLSERVER" -Newest 50

Alternatively, you can pipe the output into the Where-Object cmdlet to search the actual message text of the log for a specific keyword (like “timeout” or “corrupt”).

Get-EventLog -LogName System | Where-Object {$_.Message -like "*timeout*"}

5. Exporting for Analysis

If you need to send the logs to a vendor for support, or if you want to analyze them in Excel, PowerShell can export the queried data flawlessly.

To dump all recent errors into a CSV file:

Get-EventLog -LogName System -EntryType Error -Newest 100 | Export-Csv -Path C:\Admin\SystemErrors.csv -NoTypeInformation

Conclusion

Note: Microsoft has introduced a newer cmdlet, Get-WinEvent, designed to replace Get-EventLog for modern ETW (Event Tracing for Windows) logs. However, for quickly querying the classic System, Security, and Application logs, Get-EventLog remains the most straightforward syntax.

The graphical Event Viewer is obsolete for serious administrative tasks. By mastering PowerShell log retrieval, you can parse massive forensic databases in seconds, turning a chaotic pile of system data into actionable troubleshooting intelligence.

RELATED POSTS

  • How to Add a User to the Local Administrators Group using PowerShell
  • How to Use the INDEX and MATCH Functions for Dynamic Two-Way Lookups in Excel
  • How to Use the UNIQUE Function in Excel to Instantly Deduplicate Data Arrays
  • How to Enable the Windows Subsystem for Linux (WSL) using PowerShell
  • How to Use XLOOKUP in Excel as a Powerful Replacement for VLOOKUP
  • Get the best tech tips delivered straight to your inbox.

    Join thousands of readers mastering Apple, Google, Microsoft, and Linux.