PowerShell is a powerful scripting language that can be used to automate tasks and manage Windows systems. One of the most useful PowerShell commands is Get-NetFirewallRule, which allows you to view and manage the Windows Firewall rules on your system. In this article, we will explore the syntax, parameters, inputs, outputs, examples, and tips for using Get-NetFirewallRule.

Syntax

The syntax for Get-NetFirewallRule is as follows:

Get-NetFirewallRule [-Name] <String[]> [-DisplayName] <String[]> [-Enabled] <Boolean> [-Profile] <String[]> [-Action] <String[]> [-Direction] <String[]> [-LocalAddress] <String[]> [-RemoteAddress] <String[]> [-LocalPort] <String[]> [-RemotePort] <String[]> [-Protocol] <String[]> [-InterfaceType] <String[]> [-ApplicationName] <String[]> [-ServiceName] <String[]> [-Group] <String[]> [-CimSession] <CimSession[]> [-ThrottleLimit] <Int32> [-AsJob] [-PassThru] [-CimClass] <String> [-ComputerName] <String[]> [-Property] <String[]> [-FilterScript] <ScriptBlock> [-InputObject] <CimInstance[]> [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters

The Get-NetFirewallRule command has a number of parameters that can be used to filter the results. These parameters are as follows:

  • Name: The name of the firewall rule.
  • DisplayName: The display name of the firewall rule.
  • Enabled: Whether the firewall rule is enabled or disabled.
  • Profile: The profile of the firewall rule.
  • Action: The action of the firewall rule.
  • Direction: The direction of the firewall rule.
  • LocalAddress: The local address of the firewall rule.
  • RemoteAddress: The remote address of the firewall rule.
  • LocalPort: The local port of the firewall rule.
  • RemotePort: The remote port of the firewall rule.
  • Protocol: The protocol of the firewall rule.
  • InterfaceType: The interface type of the firewall rule.
  • ApplicationName: The application name of the firewall rule.
  • ServiceName: The service name of the firewall rule.
  • Group: The group of the firewall rule.
  • CimSession: The CimSession of the firewall rule.
  • ThrottleLimit: The throttle limit of the firewall rule.
  • AsJob: Whether to run the command as a job.
  • PassThru: Whether to pass the result through to the pipeline.
  • CimClass: The CimClass of the firewall rule.
  • ComputerName: The computer name of the firewall rule.
  • Property: The property of the firewall rule.
  • FilterScript: The filter script of the firewall rule.
  • InputObject: The input object of the firewall rule.
  • WhatIf: Whether to run the command in WhatIf mode.
  • Confirm: Whether to run the command in Confirm mode.

Inputs

The Get-NetFirewallRule command takes a number of inputs, including the parameters listed above. These inputs can be used to filter the results of the command.

Outputs

The Get-NetFirewallRule command outputs a list of firewall rules that match the specified parameters. The output includes the name, display name, enabled status, profile, action, direction, local address, remote address, local port, remote port, protocol, interface type, application name, service name, group, CimSession, throttle limit, CimClass, computer name, property, filter script, and input object of each firewall rule.

Examples

Here are some examples of how to use the Get-NetFirewallRule command:

  • To view all enabled firewall rules, use the following command: Get-NetFirewallRule -Enabled $true
  • To view all firewall rules with the name “Allow_HTTP”, use the following command: Get-NetFirewallRule -Name “Allow_HTTP”
  • To view all firewall rules with the display name “Allow HTTP”, use the following command: Get-NetFirewallRule -DisplayName “Allow HTTP”
  • To view all firewall rules with the profile “Domain”, use the following command: Get-NetFirewallRule -Profile “Domain”
  • To view all firewall rules with the action “Allow”, use the following command: Get-NetFirewallRule -Action “Allow”
  • To view all firewall rules with the direction “Inbound”, use the following command: Get-NetFirewallRule -Direction “Inbound”
  • To view all firewall rules with the local address “127.0.0.1”, use the following command: Get-NetFirewallRule -LocalAddress “127.0.0.1”
  • To view all firewall rules with the remote address “192.168.1.0/24”, use the following command: Get-NetFirewallRule -RemoteAddress “192.168.1.0/24”
  • To view all firewall rules with the local port “8080”, use the following command: Get-NetFirewallRule -LocalPort “8080”
  • To view all firewall rules with the remote port “443”, use the following command: Get-NetFirewallRule -RemotePort “443”
  • To view all firewall rules with the protocol “TCP”, use the following command: Get-NetFirewallRule -Protocol “TCP”
  • To view all firewall rules with the interface type “Ethernet”, use the following command: Get-NetFirewallRule -InterfaceType “Ethernet”
  • To view all firewall rules with the application name “MyApp.exe”, use the following command: Get-NetFirewallRule -ApplicationName “MyApp.exe”
  • To view all firewall rules with the service name “MyService”, use the following command: Get-NetFirewallRule -ServiceName “MyService”
  • To view all firewall rules with the group “MyGroup”, use the following command: Get-NetFirewallRule -Group “MyGroup”
  • To view all firewall rules with the CimSession “MySession”, use the following command: Get-NetFirewallRule -CimSession “MySession”
  • To

Leave a Reply