How to add firewall rules in group in windows Server 2008 R2

09 Mar

As many of you might meet this requirement when using windows Server 2008 r2:

  1. Create a bunch of firewall rules on similar servers manually,
  2. You just want the rules created in the same group for easy mgmt.

While you will find there is no tools available for you to change the manually created rules in the customized group name.

While after one afternoon researching, here is the PowerShell to do this task.

$fw= New-Object -ComObject hnetcfg.fwpolicy2

$fw.rules | ? {$ -like “*sql*”} | ft name,grouping

$fw.rules | ? {$ -like “*sql*”} | % {$gn=”_mssqlservices”;$_.grouping = $gn}  # change name, $gn as  your requirement

$fw.rules | ? {$ -like “*sql*”} | ft name,grouping

after the change, some changeable rule settings will be unavailable,good for me, and it is still be able to delete the whole rule.

Leave a comment

Posted by on March 9, 2013 in others


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: