gpt4 book ai didi

powershell - Enter-PSSession不适用于端口5986

转载 作者:行者123 更新时间:2023-12-03 00:00:49 25 4
gpt4 key购买 nike

Enter-PSSession命令可在端口5985的远程PC上运行,但是每当我指定端口5986(HTTPS)时,它就会显示以下错误:

Enter-PSSession : Connecting to remote server localhost failed with the
following error message : The client cannot connect to the destination
specified in the request. Verify that the service on the destination is
running and is accepting requests. Consult the logs and documentation for
the WS-Management service running on the destination, most commonly IIS
or WinRM. If the destination is the WinRM service, run the following
command on the destination to analyze and configure the WinRM service:
"winrm quickconfig". For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName localhost -Port 5986
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (localhost:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

我试图在防火墙中启用端口5986,甚至完全禁用了防火墙,但仍然无法解决问题。那么,如何为PSSession启用端口5986?

最佳答案

我遇到了这个问题。

  • 检查防火墙规则。必须允许端口5986进行入站连接。
  • 您是否在服务器上创建了证书?如果没有的话...
    以管理员身份在PowerShell中运行:
    New-SelfSignedCertificate -DnsName <your_server_dns_name_or_whatever_you_like> -CertStoreLocation Cert:\LocalMachine\My

  • 并保存返回的指纹。您将需要指纹。
  • 您是否在服务器上配置了WinRM?如果不是,则...以管理员身份运行cmd.exe并运行它:
    winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname=”<your_server_dns_name_or_whatever_you_like>”; CertificateThumbprint=”<certificate_thumbprint_from powershell>”}`
  • 尝试登录到服务器:
    $so = New-PsSessionOption –SkipCACheck -SkipCNCheck
    Enter-PSSession -ComputerName <ip_address_or_dns_name_of_server> -Credential <local_admin_username> -UseSSL -SessionOption $so

  • 也可能是您需要为客户端配置winrm。以管理员身份运行cmd.exe并运行它:
     winrm set winrm/config/client @{TrustedHosts="<ip_remote_server>"}

    关于powershell - Enter-PSSession不适用于端口5986,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30413374/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com