This article covers common commands used in the Windows Firewall and where they may be used.
The module NetSecurity is welldocumented.
Keep in mind that this article only applies to the Windows operating system.
To load the module, simply import the module as shown below.
List Existing Firewall Rules
The cmdlet,Get-NetFirewallRulewill show all existing firewall rules.
There are many, by default, so to demonstrate, we output the first 10.
There are many properties that are returned byGet-NetFirewallRule.
Though we list only a properties above, runningGet-NetFirewallRule | Select-Object * -First 1, will list all available.
TheDisplayNamemay be human readable but theNameitself assigned a random GUID.
Other useful abilities that theSet-NetFirewallRulehas is the ability to operate on multiple rules at once.
This can be done by locating rules by one of three parameters.
To do this, spin up the commandRemove-NetFirewallRule.
It’s important to note that theRemove-NetFirewallRulecan remove multiple rules at once.
An example of this key in of functionality is below.
The below rule will remove all disabled rules contained within the policyfirewall_gpoin thead.local.testdomain.
Additional Functionality
There are many other commands available within theNetSecuritymodule.
There is extensive IPSec functionality contained within the module.
The commands listed above are those that operate on the standard Windows Firewall controls.
Conclusion
There are many available commands for managing the Windows Firewall.
Even complex firewall configurations can be accomplished strictly through the command line using theNetSecurityPowerShell module!