Would you like to learn how to open a TCP port on the Windows Firewall using the Powershell? In this tutorial, we are going to show you how to use Powershell to create a firewall rule to open a port on Windows.

• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10
• Windows 7

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Related tutorial – PowerShell

On this page, we offer quick access to a list of tutorials related to PowerShell.

Tutorial Firewall – Open a TCP port using Powershell

As an Administrator, start an elevated Powershell command-line.

Windows 10 - powershell elevated

Create a firewall rule to open a TCP port using Powershell.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Verify the created firewall rule.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we created a firewall rule to allow the input on the TCP port 80 using Powershell.

Create a firewall rule to allow the input to multiple TCP ports.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Verify the created firewall rule.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we created a firewall rule to open multiple TCP ports using Powershell.

Congratulations! You are able to create a firewall rule to open a TCP port using the Powershell on Windows.

Tutorial Firewall – Open a UDP port using Powershell

As an Administrator, start an elevated Powershell command-line.

Windows 10 - powershell elevated

Create a firewall rule to open a UDP port using Powershell.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Verify the created firewall rule.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we created a firewall rule to allow the input on the UDP port 53 using Powershell.

Create a firewall rule to allow the input to multiple UDP ports.

Copy to Clipboard

Verify the created firewall rule.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we created a firewall rule to open multiple UDP ports using Powershell.

Congratulations! You are able to create a firewall rule to open a UDP port using the Powershell on Windows.

Tutorial Powershell – Managing the firewall service

As an Administrator, start an elevated Powershell command-line.

Windows 10 - powershell elevated

Configure the Windows firewall service to start automatically.

Copy to Clipboard

Start the Windows firewall service.

Copy to Clipboard

Enable the Windows firewall profiles.

Copy to Clipboard

Congratulations! You are able to manage the Firewall service using Powershell.