Powershell 无法进行本地远程处理

Powershell 无法进行本地远程处理,powershell,powershell-remoting,Powershell,Powershell Remoting,我可以对网络上的另一台机器使用Invoke命令。 我已经以管理员身份运行了启用PSRemoting PSVersion 5.0.10586.117 Windows7专业版SP1 我错过了什么 PS C:\Windows\system32> winrm quickconfig WinRM service is already running on this machine. WinRM is already set up for remote management on this comput

我可以对网络上的另一台机器使用
Invoke命令。
我已经以管理员身份运行了
启用PSRemoting

  • PSVersion 5.0.10586.117
  • Windows7专业版SP1
我错过了什么

PS C:\Windows\system32> winrm quickconfig WinRM service is already running on this machine. WinRM is already set up for remote management on this computer. PS C:\Windows\system32> Invoke-Command -ComputerName localhost -ScriptBlock { dir } [localhost] 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. + CategoryInfo : OpenError: (localhost:String) [], PSRemotingTransportException + FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
我似乎没有更改网络类型的权限。我使用的是企业VPN。company.com网络是
域网络
,而另一个网络是
公共网络
。如果我无法更改它,那么我似乎无法从这里到达那里。

这是一种称为“NTLM环回检查”的安全功能。您可以在或处查看更多详细信息。简而言之,Kerberos不能与远程主机名的“localhost”或“127.0.0.1”或“[::1]”一起使用。身份验证失败返回到NTLM,并且存在与环回IP相关的漏洞


解决方案是禁用注册表中的环回检查,如MS页面上所述,方法2。

删除WinRM旧侦听器

winrm删除winrm/config/Listener?地址=*+传输=HTTPS

首先需要创建一个自签名证书并获取其指纹

1.New-SelfSignedCertificate-DnsName”“-CertStoreLocation证书:\LocalMachine\My

将指纹复制到剪贴板并运行以下命令。此命令将在WinRM中注册HTTPS侦听器

2.winrm创建winrm/config/Listener?地址=*+Transport=HTTPS@{Hostname=“”;CertificateThumbprint=“”}

添加新的防火墙规则

port=5986
netsh advfirewall firewall add rule name="Windows Remote Management (HTTPS-In)" dir=in action=allow protocol=TCP localport=$port
  • 检查您的网络连接是否未设置为
    public
  • 在本地主机上安装远程处理
  • (1) 使用管理员权限启动新的powershell窗口(以管理员身份运行)
    (2) 使用以下命令检索本地主机名:
    hostname

    (3) 使用如下命令在受信任服务器列表中登记此主机名:
    设置项目WSMan:\localhost\Client\TrustedHosts-Value”“

  • 激活远程处理:
    Winrm qc

    启用PSRemoting

  • 测试:
    Invoke命令-ComputerName localhost-ScriptBlock{hostname}

  • 注:

  • 远程处理仅适用于提升的Powershell
  • 要从CMD提升:
    powershell-命令“启动powershell-动词RunAs”

  • 如前所述,我已将
    DisableStrictNameChecking
    设置为一(1),但仍然存在相同的故障。还有什么我需要做的吗?在一个典型的公司环境中,是否还有其他一些东西会“锁定”从而阻止它工作?对不起,我的错误。您应该禁用环回检查,这是Microsoft修复程序的第二部分。它甚至可以在不禁用严格的名称检查的情况下工作。我将编辑我的答案。
    port=5986
    netsh advfirewall firewall add rule name="Windows Remote Management (HTTPS-In)" dir=in action=allow protocol=TCP localport=$port