I am attempting to create a PowerShell script to add ip addresses to an existing Firewall rule. When I run the following only the last entry is ever added to the firewall rule.
$IPs = @("159.55.107.71", "159.55.110.45", "10.38.82.183", "10.208.165.147", "10.241.186.232", "10.241.186.234", "10.17.98.232",
"10.211.106.92", "10.208.96.181", "10.208.35.191") |`
Foreach-object {
netsh advfirewall firewall set rule name="Existing Firewall Rule" new remoteip="$_"
write-host "$_ Added $?"
}
When the script completes it shows that it has added every ip but when I check the rule I only see the last ip address in the script.
I have tried removing the brackets and spaces and adding /32 to the end and none of those options worked to add the range.
Hopefully someone can point me in the direction of where I went wrong.
- Moved by Eve WangMicrosoft contingent staff, Moderator Saturday, August 22, 2015 3:26 AM PowerShell script