April 3rd, 2015

PowerTip: Look at Most Recent Error in PowerShell

Doctor Scripto
Scripter

Summary: Learn how to see the most recent error in Windows PowerShell.

Hey, Scripting Guy! Question I ran a script that fails. How can I use Windows PowerShell to find the most recent error?

Hey, Scripting Guy! Answer Use $error, and to see the most recent error, look at error 0:

$error[0]

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.