使用DSC资源启用ICMP xFirewall创建新规则

时间:2017-02-24 22:54:55

标签: dsc

以下DSC语句复制现有的Windows防火墙规则,而不仅仅是更新已存在的相同规则。我希望它更新而不是重复。感谢

xFirewall EnableV4PingIn{
    Name = 'File and Printer Sharing (Echo Request - ICMPv4-In)'
    Group= 'File and Printer Sharing'
    Protocol = 'ICMPv4'
    Ensure='Present'
    Enabled='True'
    Direction='Inbound'
    PsDscRunAsCredential = $DomainAdminCredential

}
xFirewall EnableV4PingOut{
    Name = 'File and Printer Sharing (Echo Request - ICMPv4-Out)'
    Group= 'File and Printer Sharing'
    Protocol = 'ICMPv4'
    Ensure='Present'
    Enabled='True'
    Direction='Outbound'
    PsDscRunAsCredential = $DomainAdminCredential
}

xFirewall EnableV6PingIn{
    Name = 'File and Printer Sharing (Echo Request - ICMPv6-In)'
    Group= 'File and Printer Sharing'
    Protocol = 'ICMPv6'
    Ensure='Present'
    Enabled='True'
    Direction='Inbound'
    PsDscRunAsCredential = $DomainAdminCredential

}
xFirewall EnableV6PingOut{
    Name = 'File and Printer Sharing (Echo Request - ICMPv6-Out)'
    Group= 'File and Printer Sharing'
    Protocol = 'ICMPv6'
    Ensure='Present'
    Enabled='True'
    Direction='Outbound'
    PsDscRunAsCredential = $DomainAdminCredential
}

1 个答案:

答案 0 :(得分:0)

我明白了:)

事实证明,"姓名"在xFirewall中没有映射到"名称"显示在Windows防火墙的GUI中。

您可以运行以下命令来查看可用规则(以及它们的真实"名称"):

<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script>
<div id="app">

  <div class="btn-group" data-toggle="buttons">
    <label class="btn btn-warning" :class="{active: radio === 1}">
      <input v-model="removelines" type="radio" autocomplete="off" value="yes" v-on:click="radio = 1"> yes
    </label>

    <label class="btn btn-warning" :class="{active: radio === 2}">
      <input v-model="removelines" type="radio" value="no" v-on:click="radio = 2"> no
    </label>
  </div>
  <p>Radio is: {{radio}}</p>
  <p>Removelines is: {{removelines}}</p>

</div>

因此,您的上述内容可以简化为以下内容(适用于v4):

Get-NetFirewallRule |ft