PowerTip: Look at Most Recent Error in PowerShell

Doctor Scripto

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]