Invoke-Command failed: WinRM cannot complete the operation

走远了吗. 提交于 2019-12-13 07:28:02

问题


Using 2 machines, a local and a remote (with an address marked as remoteAddress), I'm trying to run this on the local machine:

Invoke-Command -ComputerName remoteAddress -ScriptBlock { dir c:\ }

but I get this error:

[remoteAddress] Connecting to remote server remoteAddress failed with the
following error message : WinRM cannot complete the operation. Verify that
the specified computer name is valid, that the computer is accessible over
the network, and that a firewall exception for the WinRM service is enabled
and allows access from this computer. By default, the WinRM firewall exception
for public profiles limits access to remote computers within the same local
subnet.
For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (remoteAddress:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken

I followed fixes to similiar situations. What I've checked:

  • Pinging to the remote address was successful.

  • On both machines Enable-PSRemoting -Force returned

    WinRM is already set up to receive requests on this computer.
    WinRM is already set up for remote management on this computer.
  • on both machines Set-WSManQuickConfig returned

    WinRM is already set up to receive requests on this computer.
    WinRM is already set up for remote management on this computer.

But still, I get this error trying to connect to the remote machine.


I ran test-wsman -ComputerName _remote-machine_ -Port 5985 from my local-machine And I got this error:

test-wsman : WinRM cannot complete the operation. Verify that the specified computer
name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service
is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits
access to remote computers within the same local subnet. 
At line:1 char:1
+ test-wsman -ComputerName _remote_ -Port 5985
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (_remote-machine_:String) [Test-WSMan], InvalidOperationExcept
   ion
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand

回答1:


Did you add the remotes to your local trusted host list? If not you can add them via

winrm s winrm/config/client '@{TrustedHosts="RemoteComputer"}'


来源:https://stackoverflow.com/questions/40703460/invoke-command-failed-winrm-cannot-complete-the-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!