首页 文章

Invoke-Command失败:WinRM无法完成操作

提问于
浏览
0

使用2台机器,本地和远程(地址标记为 remoteAddress ),我正在尝试在本地计算机上运行:

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

但我得到这个错误:

[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

我跟着修复了类似的情况 . 我检查了什么:

  • 已成功ping到远程地址 .

  • 在两台机器上 Enable-PSRemoting -Force 返回

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

两台机器上

  • Set-WSManQuickConfig 返回
WinRM is already set up to receive requests on this computer.
WinRM is already set up for remote management on this computer.

但是,我仍然试图连接到远程计算机时遇到此错误 .


我从本地机器运行了 test-wsman -ComputerName _remote-machine_ -Port 5985 我收到了这个错误:

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 回答

  • 0

    您是否将遥控器添加到本地可信主机列表中?如果没有,您可以通过添加它们

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

相关问题