4

忽略我开始使用一个新的进程:Powershell的开始处理在远程会话

$removeArguments = "-Command `"&{import-module .\deploy-utility.psm1; RemoveSolutions -solutionNames $solutionNames -url $url;}`"" 
start-process powershell -ArgumentList $removeArguments -Wait 

在本地运行,但在远程会话中运行时,语句简单地忽略这工作得很好。

我也尝试将命令移动到单独的文件,但这没有什么区别。

$removeArguments = "-File .\deploy-utility-functions.ps1", "remove", "$solutionNames", "$url" 
$script = {start-process powershell -ArgumentList $removeArguments -Wait -NoNewWindow | Out-Host} 
Invoke-Command -ScriptBlock $script 

远程呼叫:

$script = [scriptblock]::create("& '.\$targetFile' '$arguments'") 
$result = Invoke-Command -Session $s -ScriptBlock $script 

有什么建议?

回答

1

您可能在第二跳远程会话中具有权限问题(在您的案例中已启动进程的权限)。 请参阅启用credssp http://ss64.com/ps/enable-wsmancredssp.html

+0

远程调用本身已启动,并且Start-Process之前和之后的所有操作均正常运行。 这只是开始过程似乎被忽略。 – 2013-02-22 15:46:00

+0

远程呼叫本身以及在该会话中运行的命令是“第一跳”。 – mjolinor 2013-02-22 15:55:48

+0

如果第二个进程在同一台机器上启动,它会算作“第二跳”吗? – 2013-02-24 22:12:03