Windows Adding Firewall Rules With PowerShell

KB ID 0001538

Problem

There was a question on Experts Exchange this morning, the asker wanted to be able to add a ‘Trusted’ network range to their Windows Server Firewall settings as a ‘allow all ports’ rule.

Solution

You can of course add this manually in the GUI, normally I’d simply Add a Firewall Rule with a Group Policy. but the problem with that is, that’s fine if you want to open a particular TCP/UDP/ICMP port, but NOT if you want to open ALL ports. But you CAN use PowerShell like so;

New-NetFirewallRule -RemoteAddress 192.168.100.0/24 -DisplayName "Trusted Subnet" -Direction inbound -Profile Any -Action Allow

Add Subnet to Firewall

Then you can check the settings, just as if you had created the rule in the GUI.

Powershell Add Subnet to Firewall

Powershell Add Trusted Subnet to Firewall

 

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

1 Comment

  1. This helps a lot, after creating the rule, how to modify the rule, adding to the rule, removing the range or specific ip’s

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *