The New-NetFirewallRule command is a powerful Windows PowerShell command that enables you to create and configure firewall rules on your computer. This command is part of the NetSecurity module, which is included in Windows 10 and Windows Server 2016 and later. With this command, you can create rules to allow or deny network traffic based on a variety of criteria, such as source and destination IP addresses, port numbers, and protocols.
The New-NetFirewallRule command is a great way to manage your computer’s firewall settings. It is easy to use and provides a lot of flexibility. In this article, we will discuss the syntax, parameters, inputs, outputs, examples, and tips for using the New-NetFirewallRule command.
Syntax
The syntax for the New-NetFirewallRule command is as follows:
New-NetFirewallRule [-Name]
Parameters
The New-NetFirewallRule command has the following parameters:
Parameter | Description |
---|---|
Name | Specifies the name of the firewall rule. |
DisplayName | Specifies the display name of the firewall rule. |
Description | Specifies the description of the firewall rule. |
Group | Specifies the group name of the firewall rule. |
Profile | Specifies the profile of the firewall rule. |
Direction | Specifies the direction of the firewall rule. |
Action | Specifies the action of the firewall rule. |
Enabled | Specifies whether the firewall rule is enabled or disabled. |
LocalAddress | Specifies the local address of the firewall rule. |
RemoteAddress | Specifies the remote address of the firewall rule. |
Protocol | Specifies the protocol of the firewall rule. |
LocalPort | Specifies the local port of the firewall rule. |
RemotePort | Specifies the remote port of the firewall rule. |
Program | Specifies the program of the firewall rule. |
Service | Specifies the service of the firewall rule. |
InterfaceType | Specifies the interface type of the firewall rule. |
EdgeTraversalPolicy | Specifies the edge traversal policy of the firewall rule. |
LooseSourceMapping | Specifies whether loose source mapping is enabled or disabled. |
LocalUser | Specifies the local user of the firewall rule. |
LocalComputer | Specifies the local computer of the firewall rule. |
RemoteUser | Specifies the remote user of the firewall rule. |
RemoteComputer | Specifies the remote computer of the firewall rule. |
CimSession | Specifies the CimSession of the firewall rule. |
ThrottleLimit | Specifies the throttle limit of the firewall rule. |
AsJob | Specifies whether the command should be run as a background job. |
PassThru | Specifies whether the command should return the object that was created. |
WhatIf | Specifies whether the command should simulate the actions that it would take on the object. |
Confirm | Specifies whether the command should prompt for confirmation before executing. |
Inputs
The New-NetFirewallRule command accepts the following inputs:
- Name
- DisplayName
- Description
- Group
- Profile
- Direction
- Action
- Enabled
- LocalAddress
- RemoteAddress
- Protocol
- LocalPort
- RemotePort
- Program
- Service
- InterfaceType
- EdgeTraversalPolicy
- LooseSourceMapping
- LocalUser
- LocalComputer
- RemoteUser
- RemoteComputer
- CimSession
- ThrottleLimit
- AsJob
- PassThru
- WhatIf
- Confirm
Outputs
The New-NetFirewallRule command returns a NetFirewallRule object if the PassThru parameter is specified. This object contains information about the firewall rule that was created.
Examples
Here are some examples of how to use the New-NetFirewallRule command:
- To create a new firewall rule to allow traffic from a specific IP address on port