【发布时间】:2017-03-27 22:49:21
【问题描述】:
我正在尝试在远程会话上运行命令,但我得到了一个
无法索引到空数组。 + CategoryInfo : InvalidOperation: (:) [], RuntimeException + 完全限定错误 ID:NullArray + PSComputerName : 服务器名称
我已经检查了我传递给远程会话的所有参数,它们都不是空的。以下是命令:
Invoke-Command -Session $session -ScriptBlock {Start-Process $args[0] -ArgumentList $args[1] -RedirectStandardOutput $args[2] -RedirectStandardError $agrs[3]} -Args $Consoledir,$arguments,$stdOutLog,$stdErrLog;
我正在使用此命令来运行在 $dir 参数 (D:\Temp\console.exe) 中传递的控制台应用程序。此应用程序进一步采用 $arguments 参数中传递的一些参数。
【问题讨论】:
-
看来你打错了:
$agrs[3]=>$args[3]