2010-10-11 154 views
1

我無法使用sysocmgr.exe在遠程服務器上運行Windows組件的遠程安裝。它與psexec.exe \\ServerName -i sysocmgr.exe /i:%wnidir%\inf\sysoc.inf /u:\\path\to\components.txt一起工作,但我想使用PowerShell遠程實現相同的結果。使用powershell remoting在遠程服務器上運行sysocmgr.exe

我有WinRM的PowerShell遠程工作正常,但我無法使用PowerShell遠程運行sysocmgr.exe。

我所做的這兩個服務器(本地和遠程)上:

  1. Set-ExecutionPolicy unrestricted
  2. Enable-PSRemoting - OK
  3. Set-Item WSMan:\localhost\Client\TrustedHosts *
  4. 我已經重新啓動WinRM服務,並且它是工作

所有這一切都在兩臺服務器上工作,我建立了一個持久性遠程會話中使用新的PSSession:

$s = NewPSSession -ComputerName Server1 

然後我試圖發動PowerShell腳本(script.ps1),它保存在訪問共享給所有服務器,幷包含:

sysocmgr.exe /i:%wnidir%\inf\sysoc.inf /u:\\path\to\components.txt 

我用調用命令:

Invoke-Command -Session $s -FilePath \\NetworkShare\Scripts\script.ps1 

推出上述調用命令我可以在任務管理器中的遠程服務器(服務器)上看到後,那sysocmgr.exe運行,但不起任何作用。 Windows組件安裝程序沒有啓動...

我試着使用:

enter-pssession -computername Server1 - 工作得很好 嘗試啓動script1.ps1和它做同樣的事情,我可以看到在任務的sysocmgr.exe經理,但它什麼都不做......

我想我錯過了一些參數與桌面交互,就像在PSEXEC的「-i」參數,我不能在PowerShell中找到...

謝謝您的幫助。

回答

0

我希望你的PowerShell腳本,看起來像這樣:

sysocmgr.exe "/i:${env:windir}\inf\sysoc.inf" "/u:\path\to\components.txt" 
+0

不幸的PowerShell可以處理兩種類型的變量,儘管%WINDIR%正常工作,以及在$ {ENV:WINDIR}但也解決了問題。我也添加了雙引號,但它仍然不起作用... – kubusz 2010-10-12 07:30:08

+0

PowerShell本身不會識別「%var%」。順便說一句,在你的文章或者你的代碼中是錯字「%wnidir%」嗎? – JasonMArcher 2010-10-13 16:45:20

+0

你有沒有解決你的問題?我有你看到的excact問題.. – Sune 2012-01-12 14:54:59

相關問題