问题描述
Ignoring an errorlevel != 0 in Windows PowerShell (ISE)
我已经阅读了此链接,但不确定如何运行“ Invoke-Command”,我的$ ErrorActionPreference是“ continue”。
这是我得到的错误:
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}