【问题标题】:Enable-PSRemoting returns error Unable to check the status of the firewallEnable-PSRemoting 返回错误无法检查防火墙的状态
【发布时间】:2018-09-18 00:49:32
【问题描述】:

当我运行命令 Enable-PSRemoting 时,我收到以下错误:

PS C:\Windows\system32> 启用-PSRemoting

WinRM Quick Configuration
Running command "Set-WSManQuickConfig" to enable remote management of this computer by using the Windows Remote
Management (WinRM) service.
 This includes:
    1. Starting or restarting (if already started) the WinRM service
    2. Setting the WinRM service startup type to Automatic
    3. Creating a listener to accept requests on any IP address
    4. Enabling Windows Firewall inbound rule exceptions for WS-Management traffic (for http only).

Do you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): a
WinRM is already set up to receive requests on this computer.
Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2"
Machine="localhost"><f:Message><f:ProviderFault provider="Config provider"
path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"
Code="2" Machine="my_laptop.ad.mydomain.com"><f:Message>Unable to check the status of the firewall.
</f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:69 char:17
+                 Set-WSManQuickConfig -force
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

据我所知,当 PC 在公共网络上时,应该会发生此错误。这台 PC 不在公共网络上,而是加入了域。运行 Get-NetConnectionProfile 确认 DomainAuthenticated 网络状态。如何解决此问题并让 Enable-PSRemoting 正常运行?

我有一台运行 Powershell 4.0 的 Windows 8 PC。

【问题讨论】:

  • (Get-NetConnectionProfile).NetworkCategory 返回什么?如果在Enable-PSRemoting 上使用-Force 参数会发生什么?你的会话提升了吗?错误消息反映了获取/设置防火墙规则的问题。
  • (Get-NetConnectionProfile).NetworkCategory 返回 DomainAuthenticated
  • 我的会话被提升了,不管有没有 -Force 参数,结果都是一样的。
  • 我也尝试关闭防火墙并在关闭的情况下运行命令,但没有任何区别。
  • 您是否测试过该命令实际上失败了?你的防火墙启用了吗?你能验证规则是否到位? Get-NetFirewallRule -All | ? Description -like '*5985*'

标签: windows powershell powershell-4.0 powershell-remoting


【解决方案1】:

设置 PSRemoting 的最佳方式是通过组策略。您需要配置以下设置。

设置监听器:

/Computer Configuration
    /Administrative Templates
    /Windows Components
    /Windows Remote Management (WinRM)
    /WinRM Service
        /Allow remote server management through WinRM
            - Enabled
            - IPv4 filter: *

设置防火墙规则:

/Computer Configuration
    /WindowsSettings
    /Security Settings
    /Windows Firewall with Advanced Security
        /Inbound Rules
            - Type: Port
            - Protocol: TCP
            - Port: 5985
            - Allow the connection
            - Profile: Domain
        /Outbound Rules
            - Type: Port
            - Protocol: TCP
            - Port: 5985
            - Allow the connection
            - Profile: Domain

设置服务:

/Computer Configuration
    /WindowsSettings
    /Security Settings
        /System Services
        /Windows Remote Management (WS-Management)
            - Startup mode: Automatic
            > Define this policy setting
                - Service name: WinRM
                - Service action: Start Service
                - Set all Recovery tab actions: Restart the Service

配置您的策略后,WinRM 应该可以正常工作。您可以使用以下方法验证远程处理是否正常工作:

# this tests against the FQDN
Test-WSMan -ComputerName [Net.Dns]::GetHostEntry($Env:COMPUTERNAME).HostName

【讨论】:

  • WinRM 的策略设置实际上在这里找到: /Computer Configuration /Preferences /Control Panel Settings /Services 有趣的是,即使 /Security Settings/System Services 设置下的启动模式被定义为 Automatic,在控制面板设置/服务/WinRM 下,根据我之前提到的指令集,它仍然被定义为无更改。我改变了它以使两个设置统一。将应用它并让您知道会发生什么。
  • @user1780242 可能是操作系统版本之间的差异
  • *您确定出站端口规则是必要的吗?我在测试机器上使用本地配置进行了一些测试,禁用它并没有什么不同。
  • 可能不需要出站。我知道该协议通过 5985 (http)/5986 (https) 进行通信,但您可能是对的,它对于传出 @user1780242 是动态的
  • 仅供参考——我已经找出了我遇到的问题。我在 /Computer Configuration/Policies/Administrative Templates/Windows Components/Windows Remote Management/WinRM Service 的 WinRM 服务设置中放置了一个 IP 过滤器,以限制到我的本地子网,这就是阻塞。当我用 * 替换它时,它开始工作。我想我应该在防火墙规则中而不是在服务配置中这样做。非常感谢您的宝贵时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-11-09
  • 2016-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多