The Difference Between $? and $LASTEXITCODE in PowerShell
PowerShell has two automatic variables that can help you determine whether a command succeeded or failed: $? and $LASTEXITCODE. At first glance, they seem to do pretty much the same thing. However, they work very differently, and understanding those differences…