Why doesn't Get-NetFirewallRule show all information of the firewall rule?

dave zhou picture dave zhou · Feb 8, 2017 · Viewed 7k times · Source

I'm trying to find if a firewall rule already existing, with the same name, same configuration, like: localport.

So I use Get-NetFirewallRule to list all rules, but the rules returned do not contain the information of port, also some other information are missing. where can I find all the config of a rule. Below is the attributess returned:

Name
DisplayName
Description
DisplayGroup
Group
Enabled
Profile
Platform
Direction
Action
EdgeTraversalPolicy
LooseSourceMapping
LocalOnlyMapping
Owner
PrimaryStatus
Status
EnforcementStatus
PolicyStoreSource
PolicyStoreSourceType

Answer

Uisgebeatha picture Uisgebeatha · Nov 6, 2017

In order to find the port numbers that are already in the firewall rules, you can use a different cmdlet Get-NetFirewallPortFilter.

(Info)

Use Get-NetFirewallRule to filter which subset of rules you want to look at and pipe it to the above cmdlet. eg.:

Get-NetFirewallRule -DisplayName "SQL Broker Service" | Get-NetFirewallPortFilter

Sounds like the property you are after is localport.