May 5th, 2013

PowerTip: Use PowerShell to Troubleshoot PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to troubleshoot errors with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to troubleshoot issues with Windows PowerShell?

Hey, Scripting Guy! Answer Use the Get-WinEvent cmdlet to parse the Windows PowerShell log. For example, to find all errors in a Windows PowerShell log:

In Windows PowerShell 3.0:

Get-WinEvent -LogName *powershell* | where leveldisplayname -eq ‘error’

In Windows PowerShell 2.0:

Get-WinEvent -LogName *powershell* | where {$_.LevelDisplayName -eq ‘error’}

You can also group by the error ID to get an idea of how often a particular error appears:

In Windows PowerShell 3.0:

Get-WinEvent -LogName *powershell* | where leveldisplayname -eq ‘error’ | group id

In Windows PowerShell 2.0:

Get-WinEvent -LogName *powershell* | where {$_.LevelDisplayName -eq ‘error’} | group id

 

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.