2011-09-07 101 views
8

我想更遠的服務器上執行以下語句:PowerShell:錯誤執行命令使用Invoke-Command?

Invoke-Command -ComputerName server1 -ScriptBlock {Get-Process} 

,但我得到一個錯誤信息:

[server1] Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the serv 
ice on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS 
or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more 
information, see the about_Remote_Troubleshooting Help topic. 
    + CategoryInfo   : OpenError: (:) [], PSRemotingTransportException 
    + FullyQualifiedErrorId : PSSessionStateBroken 

,這是什麼,以及如何解決它的原因是什麼?

+3

試在遠程計算機中鍵入Enable-PSRemoting。 –

回答

16

有2 basical原因:

1)遠程計算機上沒有安裝PowerShell的

2)PSremoting不遠程計算機上啓用(啓用它讀我的評論在您回答)

+1

啓用-PSRemoting幫助! – jrara

+0

PS:在我的情況下「Enable-PSRemoting」還不夠,我不得不在「Enable-WSManCredSSP -Role Server」之後運行才能工作。 – expirat001