如何通过命令提示符创建Windows 2008 Advanced Firewall规则组定义

有没有办法在 Windows高级防火墙中创建组或添加到现有组的规则(最好通过命令提示符或WSH脚本).

编辑:

找到了这个老问题的解决方案,这个问题一直困扰着我很久!

New-NetFirewallRule TechNet文章说明了有关New-NetFirewallRule命令行开关的-Group参数:

[…] This
parameter specifies the source string for the displayGroup parameter.
[…] Rule groups can be used to
organize rules by influence and allows batch rule modifications. Using
the Set-NetFirewallRule cmdlets,if the group name is specified for a
set of rules or sets,then all of the rules or sets in that group
receive the same set of modifications. It is a good practice to
specify this parameter value with a universal and world-ready indirect
@FirewallAPI name.

Note: The displayGroup parameter cannot be specified upon object
creation using the New-NetFirewallRule cmdlet,but can be modified
using dot-notation and the Set-NetFirewallRule cmdlet.

听起来有机会,对吧?在尝试了解如何自己完成此操作时,我运行了以下内容

Get-NetFirewallRule -displayName "Core Networking - IPv6 (IPv6-In)" | Get-Member

…并注意到displayGroup属性只有Get方法,但Group属性(带有RuleGroup别名)同时具有Get和Set方法.

PowerShell解决方案如下:

感谢@maoizm,此解决方案现在可用于存在一个或多个具有相同displayName的规则:

$RuleName = "NameOfYourFirewallRuleGoesHere"
$RuleGroup = "YourGroupNameGoesHere"
Get-NetFirewallRule -displayName $RuleName | ForEach { $_.Group = '$RuleGroup'; Set-NetFirewallRule -InputObject $_ }

这实际上会创建一个分配给您的规则的新组名.

注意:netsh命令没有add group命令.请在此处查看Netsh AdvFirewall Firewall Commands的语法.

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...