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

问题描述 投票:0回答:1

当我运行命令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。

windows powershell powershell-v4.0 powershell-remoting
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.