What is `$?` in Powershell?

后端 未结 4 742
北荒
北荒 2020-12-01 15:22

What is the meaning of $? in Powershell?


Edit: TechNet answers in tautology, without explaining what \'succeed\' or \'fail\' mean.

4条回答
  •  星月不相逢
    2020-12-01 15:57

    You can also access last commands exit code using $LastExitCode parameter.

    # run some command
    # ...
    if ((! $?) -and $ErrorAction -eq "Stop") { exit $LastExitCode }
    

提交回复
热议问题