Summary: Learn how to examine the most recent error in Windows PowerShell.
My Windows PowerShell command failed with an error. How can I look at the error record?
Use the $error automatic variable to it displays the last error.
You can see more details by piping it to the Format-List cmdlet and using –Force:
$error | Format-List * -Force