PowerShell can be used to create, edit, or remove Windows Firewall rules. To create a new rule, use the New-WindowsFirewallRule cmdlet.
To edit an existing rule, use the Set-WindowsFirewallRule cmdlet. To remove a rule, use the Remove-WindowsFirewallRule cmdlet.
To create a new rule, use the New-WindowsFirewallRule cmdlet. The following syntax is used to create a new rule:
New-WindowsFirewallRule -Name
The following is a list of the parameters that can be used in the New-WindowsFirewallRule cmdlet:
-Name
This parameter is used to name the new rule. The name can be up to 64 characters long.
-Description
This parameter is used to provide a description of the new rule.
-Enabled
This parameter is used to determine whether the new rule is enabled. The default value is True.
-Exceptions
This parameter is used to specify the list of exceptions that the new rule will apply to.
-Action
This parameter is used to specify the action that the new rule will take. The possible values are:
-Allow
This value specifies that the new rule will allow traffic through the firewall.
-Block
This value specifies that the new rule will block traffic through the firewall.
-Deny
This value specifies that the new rule will deny traffic through the firewall.
-Notification
This value specifies that the new rule will generate a notification when a violation occurs.
-Profile
This parameter is used to specify the profile to which the new rule will be applied. The possible values are:
-Default
This value specifies that the new rule will be applied to the default profile.
-Private
This value specifies that the new rule will be applied to the private profile.
-Public
This value specifies that the new rule will be applied to the public profile.
After you have created the new rule, you can use the Get-WindowsFirewallRule cmdlet to view the details of the rule.
To edit an existing rule, use the Set-WindowsFirewallRule cmdlet. The following syntax is used to edit a rule:
Set-WindowsFirewallRule -Name
The following is a list of the parameters that can be used in the Set-WindowsFirewallRule cmdlet:
This parameter is used to name the rule.
This parameter is used to provide a description of the rule.
This parameter is used to determine whether the rule is enabled.
This parameter is used to specify the list of exceptions that the rule will apply to.
This parameter is used to specify the action that the rule will take. The possible values are:
This value specifies that the rule will allow traffic through the firewall.
This value specifies that the rule will block traffic through the firewall.
This value specifies that the rule will deny traffic through the firewall.
This value specifies that the rule will generate a notification when a violation occurs.
This parameter is used to specify the profile to which the rule will be applied. The possible values are:
This value specifies that the rule will be applied to the default profile.
This value specifies that the rule will be applied to the private profile.
This value specifies that the rule will be applied to the public profile.
After you have edited the rule, you can use the Get-WindowsFirewallRule cmdlet to view the details of the rule.
To remove a rule, use the Remove-WindowsFirewallRule cmdlet. The following syntax is used to remove a rule:
Remove-WindowsFirewallRule -Name
The following is a list of the parameters that can be used in the Remove-WindowsFirewallRule cmdlet:
This parameter is used to name the rule.
This parameter is used to specify the profile to which.