使用 VS 代码版本:1.44.2(系统设置(。
$error.clear()
Write-Host "this is the error message"
Write-Host "the result is $($?)"
$null -eq $LASTEXITCODE
Write-Host "lec is $($LASTEXITCODE)"
$LASTEXITCODE
我用过$error。在开始调试之前清除((。
PS C:srct> $error.clear()
PS C:srct> $error
PS C:srct> c:srctTrap.ps1
### debugging started, beak on first statement, $error already has an entry
[DBG]: PS C:srct> $error
The term '__Invoke-ReadLineForEditorServices' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
[DBG]: PS C:srct>
这是一个官方错误,早已为人所知,尚未修复。
https://github.com/PowerShell/PowerShellEditorServices/issues/1295