Adding many IP addresses to Windows Firewall using CLI fails partially
- by Thomas
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?