Did It Work? `$?`, `$LASTEXITCODE`, `&&` and `||`

$? says whether the last command worked, $LASTEXITCODE holds the number a program ended with (0 when it worked), && runs the next command only if the last one worked, and || runs it only if the last one failed.

Updated

Cheat sheet for the lesson Did It Work? `$?`, `$LASTEXITCODE`, `&&` and `||`: $? says whether the last command worked, $LASTEXITCODE holds the number a program ended with (0 when it worked), && runs the next command only if the last one worked, and || runs it only if the last one failed.
Category
PowerShell
Level
Apprentice
Tags
automatic-variable, boolean, exit-code, pipeline-chain-operator, powershell