Ensure Firewall Rule
  • 14 May 2021
  • 1 Minute to read
  • Dark
    Light
  • PDF

Ensure Firewall Rule

  • Dark
    Light
  • PDF

Article Summary

This is generated from the built in components of Otter 3.0.0, and may be different than what you have installed (especially if you have extensions); go to [User Icon] -> Documentation within your BuildMaster instance to see exactly what operations are available.

Ensure Firewall Rule

Ensures the existence of a firewall rule on a Windows server.

Script usage:

Firewall::Ensure-NetFirewallRule(
	Name: <text>,
	Profiles: <text>,
	Port: <text>,
	Protocol: <text>,
	Inbound: <true/false>,
	Allow: <true/false>,
	[Exists: <true/false>]
);

Arguments:

NameFormatScript UsageUsage Notes
Name
text
Name
This argument is required.
Profiles
text
Profiles
Specify a comma separated list of profiles: "Public", "Private", and/or "Domain". (ex: "Public, Private") This argument is required.
Port or Port Range
text
Port
Specify the port(s) affected by the firewall rule. Ports can be a comma separated list or a port range specified as "start-end" ex: 80-81,443 This argument is required.
Protocol
text
Protocol
Specify if the protocol is "UDP" or "TCP" This argument is required.
Inbound
true/false
Inbound
Specify if the connection is Inbound or Outbound. (Default = true) This argument is required.
Allow
true/false
Allow
Select if you want to Allow or Block a connection. (Default = true) This argument is required.
Exists
true/false
Exists

Example:

# ensures that TCP ports 80 and 443 are allowed on "Domain" and Private profiles in Window's Firewall
Firewall::Ensure-NetFirewallRule(
    Name: OtterHttpTCP80443,
    Profiles: "Domain, Private",
    Port: "80,443",
    Protocol: TCP,
    Inbound: true,
    Allow: true
);


# ensures that UDP ports 5000 through 5004 and 5008 are allowed on the "Domain" profile Window's Firewall
Firewall::Ensure-NetFirewallRule(
    Name: OtterHttpUdpTest,
    Profiles: "Domain",
    Port: "5000-5004,5008",
    Protocol: UDP,
    Inbound: true,
    Allow: true
);

# ensures that the "OtterHttpTCP80443" Window's Firewall rule is removed
IIS::Ensure-Site(
    Name: OtterHttpTCP80443,
    Exists: false
);

Was this article helpful?

ESC

Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses