调用命令失败:WinRM 无法完成操作 [英] Invoke-Command failed: WinRM cannot complete the operation
问题描述
使用 2 台机器,本地和远程(地址标记为 remoteAddress
),我试图在本地机器上运行它:
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:\ }
但我收到此错误:
[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:
ping 远程地址成功.
Pinging to the remote address was successful.
在两台机器上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.
但是,我仍然在尝试连接到远程机器时遇到此错误.
But still, I get this error trying to connect to the remote machine.
我从我的本地机器运行 test-wsman -ComputerName _remote-machine_ -Port 5985
然后我得到这个错误:
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
推荐答案
您是否有与计算机的活动远程会话(例如远程桌面)?
Do you have an active remote session, like Remote Desktop, to the computer?
我经历过这可能是 Invoke-Command 失败的唯一原因.
I have experienced that that can be the only reason for Invoke-Command to fail.
这篇关于调用命令失败:WinRM 无法完成操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!