# Chaining

Chaining: Did It Work? \`$?\`, \`$LASTEXITCODE\`, \`&&\` and \`||\`.

Updated: November 10, 2026

1. [Did It Work? \`$?\`, \`$LASTEXITCODE\`, \`&&\` and \`||\`](https://www.ask-codey.com/lessons/powershell-did-it-work) (Apprentice): $? 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.

Source: https://www.ask-codey.com/courses/powershell-in-depth/topics/powershell-chaining
