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