powershell - 忽略 Windows PowerShell (ISE) 中的错误级别 != 0

标签 powershell

我有一个运行外部 EXE 文件的脚本。当该 EXE 文件失败(将错误级别设置为 1)时,PowerShell 脚本将失败。

我正在运行 curl.exe 并得到这个:

  • CategoryInfo : NotSpecified: ( % Total % ... Time Current:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError


如何忽略/捕获外部 EXE 文件的故障并继续执行我的脚本?

最佳答案

这与 EXE 返回的退出代码没有任何关系。当 EXE 写入 stderr 时会生成错误,但仅在 ISE 内或远程处理或使用后台作业时生成。

写入 stderr 的 EXE 不会从常规 PowerShell 命令提示符生成错误。我不确定为什么会这样。

关于powershell - 忽略 Windows PowerShell (ISE) 中的错误级别 != 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1394084/

相关文章:

class - Powershell:创建类

powershell - 检查文件是否存在并在PowerShell中运行批处理文件?

windows - GetScheduled-Job 不返回任何工作

.Net Windows 更新查询

powershell - Get-WMIObject 返回一个没有描述的错误

.net - 从 PowerShell 暂停或休眠

powershell - 无法从文件/应用程序打开/读取本地数据

powershell - 新的 Azure 资源组 powershell

excel - 是否可以使用 Import-Csv 将连续分隔符视为一个分隔符?

powershell - 为什么 Powershell 现在总是以管理员身份运行?