How does echo $? work?


I am writing some PowerShell scripts to do some build automation. I found here that echo $? returns true or false depending on previous statement. I just found that echo is alias for Write-Output. Write-Host $? also works. But I am still not clear how this $? works. Can someone kindly say some words bout this. Searching for echo $? on net did not give me much.


You find a complete Punctuation chart here. The answer (taken from the chart):

Execution status of the last operation ($true or $false); contrast
with $LastExitCode that reports the exit code of the last
Windows-based program executed.


How does echo $? work? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply