TestimoX

API Reference

Command

New-CxFirewallRule

Namespace ComputerX.PowerShell
Outputs
System.Boolean

Creates a Windows Firewall rule.

Examples

Authored help example

Example 1


New-CxFirewallRule -Name "Allow-App" -Direction Inbound -Program "C:\\Tools\\app.exe" -Protocol Any
        

Example 2


New-CxFirewallRule -Name "Allow-HTTPS" -Direction Inbound -Protocol Tcp -LocalPort 443
        

Example 3


New-CxFirewallRule -Name "Block-Range" -Direction Outbound -Protocol Udp -RemotePortRange "5000-5010" -Block
        

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -Program <string> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: Set 1

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
Program string requiredposition: namedpipeline: false
Full path to the program (program-based rules).
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -Program <string> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: Set 2

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
Program string requiredposition: namedpipeline: false
Full path to the program (program-based rules).
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -LocalPort <int> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: By LocalPort

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
LocalPort int requiredposition: namedpipeline: false
Gets or sets the LocalPort parameter.
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -LocalPortRange <string> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: By LocalPortRange

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
LocalPortRange string requiredposition: namedpipeline: false
Gets or sets the LocalPortRange parameter.
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -RemotePort <int> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: By RemotePort

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
RemotePort int requiredposition: namedpipeline: false
Gets or sets the RemotePort parameter.
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean

New-CxFirewallRule -Name <string> -Direction <Inbound|Outbound> -Protocol <Tcp|Udp|Any> -RemotePortRange <string> [-Block] [-Profiles <Domain|Private|Public|All>] [<CommonParameters>]
#
Parameter set: By RemotePortRange

Parameters

Name string requiredposition: 0pipeline: false
Name identifier for the firewall rule.
Direction FirewallDirection requiredposition: 1pipeline: falsevalues: 2
Inbound or Outbound. Possible values: Inbound, Outbound
Possible values: Inbound, Outbound
Protocol FirewallProtocol requiredposition: 2pipeline: falsevalues: 3
Protocol to use. Any (program rules only), or Tcp/Udp for port rules. Possible values: Tcp, Udp, Any
Possible values: Tcp, Udp, Any
RemotePortRange string requiredposition: namedpipeline: false
Gets or sets the RemotePortRange parameter.
Block SwitchParameter optionalposition: namedpipeline: false
Block instead of allow. Default is allow.
Profiles FirewallProfileKind optionalposition: namedpipeline: falsevalues: 4
Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
Possible values: Domain, Private, Public, All

Outputs

System.Boolean