< Back
Get-CFirewallRule
Post
NAME Get-CFirewallRule
SYNOPSIS
Gets the local computer's firewall rules.
SYNTAX
Get-CFirewallRule [<CommonParameters>]
Get-CFirewallRule -Name <String> [<CommonParameters>]
Get-CFirewallRule -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.
PARAMETERS
-Name <String>
The name of the rule. Wildcards supported. Names aren't unique, so you may still get back multiple rules
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LiteralName <String>
The literal name of the rule. Wildcards not supported.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Carbon.Firewall.Rule.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-CFirewallRule
Demonstrates how to get the firewall rules running on the current computer.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-CFirewallRule -Name 'World Wide Web Services (HTTP Traffic-In)'
Demonstrates how to get a specific rule.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-CFirewallRule -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 --------------------------
PS C:\\>Get-CFirewallRule -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.
RELATED LINKS
Assert-CFirewallConfigurable
Carbon_FirewallRule
SYNOPSIS
Gets the local computer's firewall rules.
SYNTAX
Get-CFirewallRule [<CommonParameters>]
Get-CFirewallRule -Name <String> [<CommonParameters>]
Get-CFirewallRule -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.
PARAMETERS
-Name <String>
The name of the rule. Wildcards supported. Names aren't unique, so you may still get back multiple rules
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LiteralName <String>
The literal name of the rule. Wildcards not supported.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Carbon.Firewall.Rule.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-CFirewallRule
Demonstrates how to get the firewall rules running on the current computer.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-CFirewallRule -Name 'World Wide Web Services (HTTP Traffic-In)'
Demonstrates how to get a specific rule.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-CFirewallRule -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 --------------------------
PS C:\\>Get-CFirewallRule -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.
RELATED LINKS
Assert-CFirewallConfigurable
Carbon_FirewallRule