Diferencia entre $? y $ LastExitCode en PowerShell
En PowerShell, ¿cuál es la diferencia entre$?
y$LastExitCode
?
Yo leosobre variables automáticas, y se dijo:
$? Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.
$LastExitCode Contains the exit code of the last Windows-based program that was run.
En la definicion de$?
no explica lo que triunfar y fallar significa.
Pregunto porque presumo que$?
es verdadero si y solo si $ LastExitCode es 0, pero encontré un contraejemplo sorprendente:$ LastExitCode = 0 pero $? = False en PowerShell. Redirigir stderr a stdout da NativeCommandError.