August 16th, 2015

PowerTip: Looking at Logs with PowerShell

Doctor Scripto
Scripter

Summary: Find logs that are not enabled with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to quickly see which logs in the event log tool are not enabled by default?

Hey, Scripting Guy! Answer Use the Get-WinEvent cmdlet to produce a list of all the logs, then pipe the results to the Where-Object cmdlet,
           and specify that you want those that are not enabled, for example:

Get-WinEvent -ListLog * -ea 0 | where {-not ($_.isenabled)}

Note   Many logs require elevated permissions for access. Either launch Windows PowerShell with elevated rights,
or specify an error action of 0 to block error messages related to not having access.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback