Use PowerShell to find application log errors
Here's a tip from my colleague Ed Wilson (the Microsoft Scripting Guy) on how to use Windows PowerShell to find the two most recent errors from the application log. Ed Wilson is the bestselling author of eight books about Windows Scripting, including Windows PowerShell 3.0 Step by Step, and Windows PowerShell 3.0 First Steps. He writes a daily blog about Windows PowerShell call Hey, Scripting Guy! that is hosted on the Microsoft TechNet Script Center; for more PowerTips check out the Hey, Scripting Guy! blog.
Question: You need to find the two most recent errors from the application log on your local computer. How can you use Windows PowerShell to do this?
Answer: Use the Get-EventLog cmdlet specify the log name as application choose the error type of error and specify the newest 2 entries. This command appears here.
Get-EventLog -LogName application -EntryType error -Newest 2
Mitch Tulloch is an eight-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization. For more information see http://www.mtit.com