netsh advfirewall firewall

Posted by lehn0058 on Server Fault See other posts from Server Fault or by lehn0058
Published on 2012-09-27T18:30:37Z Indexed on 2012/09/28 9:40 UTC
Read the original article Hit count: 224

Filed under:
|
|
|

I am trying to write a script to configure a windows firewall (server 2008 & 2012 only) to adjust certain firewall settings after a machine has been added to a domain. I need to do this because one of the pre-installed programs on these machines we get only has the firewall rules setup for the public and private firewall profile. This script will be pushed out for other admins to use, and some of the machine will be in other languages.

The command to change an existing firewall rule is as follows:

netsh advfirewall firewall set rule name = "rule name goes here" new profile=domain

This command works great. However, I need to do this for about 10 firewall ports AND since the program could be installed on computers with different languages, I can not just pass the name of all of the firewall rules.

Is their some way to do this by supplying the port number? Or some way to specify a regular expression so I could use any rule that has a name LIKE 'test'?

© Server Fault or respective owner

Related posts about Windows

Related posts about command-line