使用 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.
但是,我在尝试连接到远程计算机时仍然遇到此错误。
I ran 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