Adding many IP addresses to Windows Firewall using CLI fails partially

Posted by Thomas on Super User See other posts from Super User or by Thomas
Published on 2013-10-27T15:38:36Z Indexed on 2013/10/27 15:55 UTC
Read the original article Hit count: 385

I have a PowerShell script which adds IP addresses to Windows Firewall using the "netsh advfirewall" command. (As described in this question: How to append netsh firewall rules, not just replace).

The problem is that when adding a lot of IP addresses (currently over 700) the string of IP addresses seems to be 'cut off' at some point. Only an X amount of the total amount of IP addresses are actually added to the firewall, the rest... not.

The script is very simple, and looks something like this:

$ip = "123.123.123.123,124.124.124.124,125.125.125.125 and so on"

netsh advfirewall firewall set rule name="*" new remoteip="$ip"

I tried to echo the string to see if it's cut off;

echo $ip

But the complete string is correctly echo'ed.

Is there some kind of string length limit for the netsh command? Or anything else that could be causing this issue?

© Super User or respective owner

Related posts about Windows

Related posts about command-line