WinRM不起作用 Connecting to remote server failed with the following error message : WinRM cannot complete the operation

当我运行下面的 powershell  脚本时:

$FarmAcct = 'domainuser' 
$secPassword = ConvertTo-SecureString 'aaa' -AsPlaintext -Force 
$global:farmCredential_ = New-Object System.Management.Automation.PsCredential $FarmAcct,$secPassword
Invoke-Command -ComputerName "172.21.4.14" -Credential $global:farmCredential_ -Scriptblock { write-host "HELLO"}

得到下面的error:

Connecting to remote server 172.21.4.14 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: (172.21.4.14:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken

我已经安装了 winrm feature 并且执行了 "enable-psremoting -force".

解决方法:

 

运行 netsh winhttp show proxy 看是否有proxy,如果有用 netsh winhttp reset proxy 重置下,就好了。

 

http://www.ldap389.info/en/2011/04/14/the-winrm-client-cannot-complete-the-operation-within-the-time-specified/

原文地址:https://www.cnblogs.com/fengwenit/p/3606927.html