Get-FirewallRule

Gets the local computer's firewall rules.

Syntax

Get-FirewallRule [<CommonParameters>]

Get-FirewallRule -Name <String> [<CommonParameters>]

Get-FirewallRule -LiteralName <String> [<CommonParameters>]

Description

Returns a Carbon.Firewall.Rule object for each firewall rule on the local computer.

In Carbon 2.4.0 and earlier, this data is parsed from the output of:

netsh advfirewall firewall show rule name=all

which only works on english-speaking computers.

Beginning with Carbon 2.4.1, firewall rules are read using the Windows Firewall with Advanced Security API's HNetCfg.FwPolicy2 object.

You can return specific rule(s) using the Name or LiteralName parameters. The Name parameter accepts wildcards; LiteralName does not. There can be multiple firewall rules with the same name.

If the firewall isn't configurable/running, writes an error and returns without returning any objects.

This function requires administrative privileges.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The name of the rule. Wildcards supported. Names aren't unique, so you may still get back multiple rules

true false
LiteralName String

The literal name of the rule. Wildcards not supported.

true false

Return Values

Carbon.Firewall.Rule.

EXAMPLE 1

Get-FirewallRule

Demonstrates how to get the firewall rules running on the current computer.

EXAMPLE 2

Get-FirewallRule -Name 'World Wide Web Services (HTTP Traffic-In)'

Demonstrates how to get a specific rule.

EXAMPLE 3

Get-FirewallRule -Name '*HTTP*'

Demonstrates how to use wildcards to find rules whose names match a wildcard pattern, in this case any rule whose name contains the text 'HTTP' is returned.

EXAMPLE 4

Get-FirewallRule -LiteralName 'Custom Rule **CREATED BY AUTOMATED PROCES'

Demonstrates how to find a specific firewall rule by name if that name has wildcard characters in it.