【问题标题】:Allowing WinRM in the Windows Firewall在 Windows 防火墙中允许 WinRM
【发布时间】:2017-02-22 06:27:14
【问题描述】:

我使用的是windows 7机器,安装了windows power shell。如何确保将 Windows 防火墙配置为允许来自工作站的 Windows 远程管理连接。例如: netsh advfirewall firewall set rule name="Windows 远程管理 (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any

我正在执行上述命令,但无法配置它。

【问题讨论】:

  • 我正在调整问题和标签,因为这与 Chef 本身无关,只是设置 WinRM。
  • Enable-PSRemoting 应该设置你需要的一切,包括防火墙规则。

标签: windows powershell winrm


【解决方案1】:

Enable-PSRemoting -force就是你要找的东西!

winrm quickconfig也是一个很好的预防措施,启动 WinRM 服务并将服务设置为自动启动

但是,如果您希望对所有 Windows 7 机器执行此操作,您可以通过 Group Policy 启用此功能

【讨论】:

  • winrm quickconfig 对我来说是必要的部分。回显如下:The following changes must be made: Configure LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.
【解决方案2】:

这取决于您使用的协议。

以下一个对我有用:

Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress Any

来源:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_troubleshooting?view=powershell-7.2#how-to-enable-remoting-on-public-networks

【讨论】:

    【解决方案3】:

    几年前我使用它连接到远程服务器并在将 WinRM 加入域之前更新它。 ($server 变量是 foreach 语句的一部分)。我的脚本的这一部分更新-:

    1. Windows 防火墙从公共到私人
    2. Windows 防火墙允许远程 WMI 访问
    3. Trusted Hosts 未加入域,因此必须添加到 TrustedHosts 列表中
    4. Windows 防火墙允许 RDP
    5. 启用 RDP:1 = 禁用; 0 = 启用
    $RequestingServer = $env:COMPUTERNAME
    #Local Server Admin Account
    [STRING] $LocalUser = "Administrator" #Obviously Change Account
    [STRING] $LocalPassword = "Password01" #Obviously Change Password
    $LocalSecurePassword = $LocalPassword | ConvertTo-SecureString -AsPlainText -Force
    $LocalCredentials = New-Object System.Management.Automation.PSCredential -ArgumentList $LocalUser, $LocalSecurePassword
    
                    #Update Windows Firewall Remotely
                    $LocalSession = New-PSSession -Computername $Server -Credential $LocalCredentials
                    Invoke-Command -Session $LocalSession -ScriptBlock {
                    
                    $AddServer = $Using:RequestingServer
                    
                    #Update Windows Firewall from Public to Private
                    Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
                    #Update Windows Firewall to allow remote WMI Access
                    netsh advfirewall firewall set rule group="Windows Management Instrumentation (WMI)" new enable=yes
                    #Update Trusted Hosts is not domain-joined and therefore must be added to the TrustedHosts list 
                    Set-Item wsman:\localhost\Client\TrustedHosts -Value $AddServer -Force
                    #Update Windows Firewall to allow RDP
                    Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
                    #Enable RDP : 1 = Disable ; 0 = Enable
                    Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
                    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多