Enable-PSRemoting returns 错误无法检查防火墙的状态

Enable-PSRemoting returns error Unable to check the status of the firewall

当我 运行 命令 Enable-PSRemoting 我得到以下错误:

PS C:\Windows\system32> 启用-PS远程处理

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 在 public 网络上时,应该会发生此错误。这台 PC 不在 public 网络上,而是加入了域。 运行 Get-NetConnectionProfile 确认 DomainAuthenticated 网络状态。我该如何解决这个问题并正确获取 Enable-PSRemoting to 运行?

我有一个 Windows 8 PC 运行ning Powershell 4.0。

设置 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