API Reference
Command
New-CxFirewallRule
Creates a Windows Firewall rule.
Examples
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 1Parameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Full path to the program (program-based rules).
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- 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 2Parameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Full path to the program (program-based rules).
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- 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 LocalPortParameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Gets or sets the LocalPort parameter.
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- 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 LocalPortRangeParameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Gets or sets the LocalPortRange parameter.
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- 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 RemotePortParameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Gets or sets the RemotePort parameter.
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- 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 RemotePortRangeParameters
- Name string
- Name identifier for the firewall rule.
- Direction FirewallDirection
- Inbound or Outbound. Possible values: Inbound, Outbound
- Possible values:
Inbound,Outbound - Protocol FirewallProtocol
- 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
- Gets or sets the RemotePortRange parameter.
- Block SwitchParameter
- Block instead of allow. Default is allow.
- Profiles FirewallProfileKind
- Profile flags: Domain, Private, Public (defaults to All). Possible values: Domain, Private, Public, All
- Possible values:
Domain,Private,Public,All
Outputs
System.Boolean