Would you like to learn how to list the open TCP ports using Powershell? In this tutorial, we are going to show you how to use Powershell to create a list of TCP ports in the listening state on a computer running Windows.

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

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 Powershell - List the open TCP ports

As an Administrator, start a new POWERSHELL command-line prompt.

Windows 10 - powershell elevated

List the current TCP connections.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

List the open TCP ports.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, we listed only TCP ports in the listening state.

Optionally, use a filter to get only the desired columns.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Optionally, sort the output based on the TCP port number.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we listed the open TCP ports in the listening state.

In our example, we organized the command output based on the TCP port number.

Congratulations! You are able to list the open TCP ports using Powershell.

Tutorial Powershell - List the TCP connections using a script

As an Administrator, start a new POWERSHELL command-line prompt.

Windows 10 - powershell elevated

List all connections to a specific destination IP address.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

List all connections to a destination TCP port.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

List the process name and ID of a local TCP port.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Congratulations! You are able to list the TCP ports information using a Powershell script.