powershell - 通过 Jenkins 运行 powershell 脚本时出现此错误:“NativeCommandError”不确定如何使用调用命令
问题描述
在 Windows PowerShell (ISE) 中忽略错误级别!= 0
我已阅读此链接,但不确定如何运行“调用命令”,我的 $ErrorActionPreference 为“继续”。
这是我得到的错误:
06:06:55 + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command '& ''E: ... 06:06:55 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 06:06:55 + CategoryInfo : NotSpecified: (root : 2020-10-...something:String) [], RemoteException 06:06:55 + FullyQualifiedErrorId : NativeCommandError
解决方案
$errorActionPreference
应该在脚本块中定义,例如:
Invoke-Command {$ErrorActionPreference = 'SilentlyContinue'; REST OF THE CODE}
推荐阅读
- vue.js - 如何在禁用时触发点击事件
在 Vue.js 中 - java - 为什么我们需要在标记清扫垃圾收集期间进行“清扫”?
- android - 带有 appbundle 和 PROGUARD 的动态功能不起作用
- encryption - Verdaccio 使用什么算法来加密 npm 注册表?
- ios - 在 swift 中使用 CAShapeLayer 填充颜色不起作用
- c# - 处理对象以清除内存
- java - 如何将一些函数从 Activity 转换为 Fragment?
- .net - GemBox.Spreadsheet 使用 .net Web 服务下载 xlsx 文件
- mysql - 在存储过程中,无法识别从选择查询返回的字段值
- linux - cron 权限有什么问题?