PowerShell:使用Invoke-Command执行命令错误?

时间:2011-09-07 09:48:17

标签: windows powershell powershell-v2.0

我正在尝试在远程服务器上执行以下语句:

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

这是什么原因以及如何解决?

1 个答案:

答案 0 :(得分:16)

有两个基本原因:

1)远程计算机没有安装Powershell

2)远程PC上未启用PSremoting(为了使其能够在您的回答中阅读我的评论)