PS> $LastExitCode
PS> $?
PS> $Error[0]
These are built-in PowerShell variables that provide additional information about the most recent error. $LastExitCode
is the final exit code of the last native application that was executed. $?
and $Error[0]
is the last error record that was generated by PowerShell.