为什么我无法使用主机名让 Powershell Remoting 工作?

问题描述 投票:0回答:1
使用服务器的

New-PSSession

 时,
HostName
不起作用,但使用
IP
时则有效。本地和远程计算机都在同一个域中。

> PS C:\Windows\system32> New-PSSession -ComputerName "SERVERNAME"

New-PSSession : [SERVERNAME] Connecting to remote server SERVERNAME failed with the  
following error message : WinRM cannot process the request. The following error occurred  
while using Kerberos authentication: Cannot find the computer SERVERNAME. Verify that the  
computer exists on the network and that the name provided is spelled correctly. For more  
information, see the about_Remote_Troubleshooting Help topic.

我还尝试了 Ping、RDP 和

Test-WSMan
,使用服务器都成功了
Hostname

关于可能出什么问题有什么想法吗?

powershell winrm
1个回答
-1
投票

似乎是 SelfSignedCertificate 问题。

删除旧的 WinRM 监听器

winrm delete winrm/config/Listener?Address=*+Transport=HTTPS

使用域名创建新的自签名证书

New-SelfSignedCertificate -DnsName "<YOUR_DNS_NAME>" -CertStoreLocation Cert:\LocalMachine\My

更新自签名证书_THUMBPRINT

winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="<YOUR_DNS_NAME>"; CertificateThumbprint="<COPIED_CERTIFICATE_THUMBPRINT>"

3.添加新的防火墙规则

$port=5986
netsh advfirewall firewall add rule name="Windows Remote Management (HTTPS-In)" dir=in action=allow protocol=TCP localport=$port

请参阅此链接了解更多信息:

http://www.visualstudiogeeks.com/devops/how-to-configure-winrm-for-https-manually

© www.soinside.com 2019 - 2024. All rights reserved.