动力外壳 $?象征

Powershell $? Symbol

PowerShell $ 的作用是什么?符号的含义及其用途是什么?

我目前在以下代码块的上下文中使用它:

Invoke-Command -Session $session -ScriptBlock { param($proc, $arg) Start-Process $proc -ArgumentList $arg -Wait } -ArgumentList $processName, $processArgs

if ($? -ne $true)
{
}

所以我假设如果 Invoke-Command 成功执行,它会提取一个布尔值,但我不确定。

谢谢!

见about_automatic_variables:

get-help about_Automatic_Variables   

$?
Contains the execution status of the last operation. It contains
TRUE if the last operation succeeded and FALSE if it failed.