【问题标题】:Enabling ICMP with DSC Resource xFirewall Creates New Rule使用 DSC 资源 xFirewall 启用 ICMP 创建新规则
【发布时间】:2017-02-24 22:54:54
【问题描述】:

以下 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
}

【问题讨论】:

  • 你有没有想出一种方法来防止这种重复?我也有同样的问题...

标签: dsc


【解决方案1】:

我想通了:)

事实证明,xFirewall 中的“名称”并未映射到 Windows 防火墙的 GUI 中显示的“名称”。

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

Get-NetFirewallRule |ft

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

xFirewall EnableV4PingIn
{
    Name = "FPS-ICMP4-ERQ-In"
    Enabled = "True"
}

xFirewall EnableV4PingOut
{
    Name = "FPS-ICMP4-ERQ-Out"
    Enabled = "True"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    • 2022-07-24
    • 1970-01-01
    • 1970-01-01
    • 2017-08-28
    • 1970-01-01
    相关资源
    最近更新 更多