相关疑难解决方法(0)

使用"invoke-command"捕获命令的返回码 - Powershell 2

我正在使用"invoke-command"在远程计算机上执行脚本.

invoke-command -computername <server_name> -scriptblock {command to execute the script}
Run Code Online (Sandbox Code Playgroud)

当有任何错误时,我的脚本返回"-1".所以,我想通过检查返回代码来确保脚本已成功执行.

我尝试如下.

$code = invoke-command -computername ....
Run Code Online (Sandbox Code Playgroud)

但它什么也没有回报.

Invoke-command捕获脚本块的返回码?

还有其他方法可以解决这个问题吗?

powershell return-value

17
推荐指数
1
解决办法
4万
查看次数

标签 统计

powershell ×1

return-value ×1