【问题标题】:PowerShell: error executing command using Invoke-Command?PowerShell:使用 Invoke-Command 执行命令时出错?
【发布时间】:2018-01-12 02:59:01
【问题描述】:

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

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

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

【问题讨论】:

  • 尝试在远程计算机中输入 Enable-PSRemoting。

标签: windows powershell powershell-2.0


【解决方案1】:

有两个基本原因:

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

2) 远程 PC 上未启用 PSremoting(要启用它,请阅读我在您回答中的评论)

【讨论】:

  • PS:在我的情况下,“Enable-PSRemoting”还不够,我必须在“Enable-WSManCredSSP -Role Server”之后运行才能使其正常工作。
猜你喜欢
  • 2017-08-04
  • 2012-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-07
  • 1970-01-01
  • 2021-02-24
  • 1970-01-01
相关资源
最近更新 更多