Is there a way to create a group, or add to an existing group, to a rule in Windows Advanced Firewall (preferable through a command prompt or WSH script).
Edit:
Is there a way to create a group, or add to an existing group, to a rule in Windows Advanced Firewall (preferable through a command prompt or WSH script).
Edit:
Rules in the Windows Firewall can be bundle together and activated or deactivated as a group.
With
netsh advfirewall
command you can add rules to the Firewall. Use the switchgroup=
for manage the AdvFirewall groups.Use something like this:
While you specifically mention
I'm gonna assume you mean using a script. With 2008, you can use powershell. Its pretty straightforward:
See this article for more detail...
Found a solution for this old question that has also been bugging me for a long time!
The New-NetFirewallRule TechNet article states this about the
-Group
parameter of the New-NetFirewallRule commandlet:That sounds like there's a chance, right? While trying to find out how to do this myself, I ran the following:
...and noted that the
DisplayGroup
property only has a Get method, but theGroup
property (with itsRuleGroup
alias) has both a Get and a Set method.The PowerShell solution is as-follows:
Thanks to @maoizm, this solution now works when 1 or more rules with the same DisplayName exist:
And this will actually create a new group name that is assigned to your rule.
Note: The
netsh
command does not have anadd group
command. See the syntax for Netsh AdvFirewall Firewall Commands here.The
netsh
command line does not have a flag for this.As an alternative to the PowerShell solutions above, the group name is part of the registry hive.
In fact, the
.wfw
Firewall export is actually a rawregf
registry hive. If you import this into the registry editor, you can see that it's a list ofREG_SZ
pipe-delimited values.Custom values are located at
Here's a snapshot of a Google Chrome firewall entry (newlines added for readability)
The "Group" is stored under
EmbedCtxt
and its value isGoogle Chrome
.... so one could assume that you can manipulate the registry value using the same technique...
Find the registry entry
...|EmbedCtx=My Custom Group|
Note #1: Code intentionally omitted since appending to an existing registry value using command prompt is very tricky.
Note #2: Without the trailing
|
, the value will be ignored.