PowerTip: Use PowerShell to Find Event Logs with Events

Doctor Scripto

Summary: Use Windows PowerShell to find all event logs that contain events.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find all traditional and non-traditional event logs that contain events?

Hey, Scripting Guy! Answer Use the Get-WinEvent cmdlet to return all event logs, use Where-Object to filter the logs that
         contain more than 0 records, and sort the results:

In Windows PowerShell 4.0 and Windows PowerShell 3.0:

Get-WinEvent -ListLog * | where recordcount -gt 0 | sort recordcount

In Windows PowerShell 2.0:

Get-WinEvent -ListLog * | where {$_.recordcount -gt 0} | sort recordcount


Discussion is closed.

Feedback usabilla icon