---
title: "How to Find Listening Ports with Netstat and PowerShell"
description: "Using netstat, ports can be discovered on Windows PCs with ease. Coupled with PowerShell and Get-NetTCPConnection, you have one handy tool."
canonical: "https://adamtheautomator.com/netstat-port/"
---

# How to Find Listening Ports with Netstat and PowerShell

> Using netstat, ports can be discovered on Windows PCs with ease. Coupled with PowerShell and Get-NetTCPConnection, you have one handy tool.

Source: https://adamtheautomator.com/netstat-port/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Find Listening Ports with Netstat and PowerShell](https://adamtheautomator.com/wp-content/uploads/2021/04/How-to-Find-Listening-and-Active-Connections-with-Netstat-and-PowerShell.jpg)

# How to Find Listening Ports with Netstat and PowerShell

[![](https://secure.gravatar.com/avatar/6fac870bd46517f209a580d0af97a407e8dbf66931a2417ce76d0a09198a43b4?s=192&d=mm&r=g)Anthony Metcalf](https://adamtheautomator.com/author/anthony-metcalf/)7 April 20213 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Using Netstat to Find Active and Listening Ports](#h-using-netstat-to-find-active-and-listening-ports)
*   [Using PowerShell to Find Active and Listening Ports](#h-using-powershell-to-find-active-and-listening-ports)
*   [Conclusion](#h-conclusion)

Connections between applications work much like conversations between humans. The conversation is started by someone speaking. If no one is listening, then the conversation doesn’t get far. How do you know who’s listening on a Windows PC? The [Netstat command-line utility](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/netstat) and the PowerShell [`Get-NetTCPConnection` cmdlet](https://docs.microsoft.com/en-us/powershell/module/nettcpip/get-nettcpconnection?view=windowsserver2019-ps).

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

In this tutorial, you will learn how to inspect listening ports and established TCP connections on your Windows computer with [Netstat](https://adamtheautomator.com/netstat-port/) and the native PowerShell command `Get-NetTCPConnection`.

## Prerequisites

If you’d like to follow along with examples in this tutorial, be sure you have:

*   A Windows PC. Any version will do. This tutorial is using Windows 10 Build 21343.1
*   PowerShell. Both Windows PowerShell and PowerShell 6+ should work. This tutorial us using PowerShell v7.2.0-preview.2

## Using Netstat to Find Active and Listening Ports

Netstat is one of those command-line utilities that seems like it’s been around forever. It’s been a reliable command-line utility to inspect local network connections for a long time. Let’s check out how to use it to find listening and established network connections.

> _Netstat has many different parameters. This tutorial will only use three of them. To learn more about what netstat can do, run `netstat /?`._

Assuming you’re on a Windows PC:

1\. Open up an [elevated command prompt](https://www.computerhope.com/jargon/e/elevated.htm) (cmd.exe).

2\. Run `netstat -a` to find all of the listening _and_ established connections on the PC. By default, netstat only returns listening ports. Using the `-a` parameter tells netstat to return listening _and_ established connections.

![Run the Netstat -a](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T151108.317.png)

Run the Netstat -a

The output above is broken out into four columns:

*   `Proto` – shows either UDP or TCP to indicate the type of protocol used.
*   `Local Address` – shows the local IP address and port that is listening. For many services, this will be 0.0.0.0 for the IP part, meaning it is listening on all network interfaces. In some cases, a service will only listen on a single Network Interface (NIC). In that case, netstat will show the IP address of the NIC. A colon separates the IP address from the port that it is listening on.
*   `Foreign Address` – shows the remote IP address the local connection is communicating with. If the `Foreign Address` is `0.0.0.0:0`, the connection is listening for all IPs and all ports. For established connections, the IP of the client machine will be shown.
*   `State` – shows the state the port is in, usually this will be `LISTENING` or `ESTABLISHED`.

3\. Now run `netstat -an`. You should now see that any names in the output have been turned into IP addresses. By default, netstat attempts to resolve many IP addresses to names.

![run netstat -an](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T151249.521.png)

run netstat -an

4\. Finally, perhaps you’d like to know the Windows processes that are listening or have these connections open. To find that, use the `-b` switch.

> _Using the `-b` switch requires an elevated command prompt or PowerShell prompt. You will get the error `The requested operation requires elevation` if you use the `-b` switch in a non-elevated prompt._

![netstat -anb](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T151434.824.png)

netstat -anb

## Using PowerShell to Find Active and Listening Ports

Now that you’ve got a chance to see how the old-school netstat utility shows active and listening ports, let’s see how to do it in PowerShell.

Using PowerShell gives you a lot more control to see just what you want, rather than having to scroll through long lists of output. The `Get-NetTCPConnection` cmdlet is much more specific than netstat about what you want to see.

> _This tutorial isn’t going to cover all of the parameters that come with the `Get-NetTCPConnection` cmdlet. If you’re curious, run `[Get-Help](https://adamtheautomator.com/powershell-get-help/) Get-NetTCPConnection -Detailed` to discover more examples._

On your Windows PC:

1\. Open up a PowerShell console as administrator.

> _The only reason you need to elevate a PowerShell console is to see the program that owns the connection (like the netstat `-b` parameter)._

2\. Run `Get-NetTcpConnection`. You’ll see output similar to what netstat provided. Instead of just a big string of output, `Get-NetTcpConnection` returns a list of PowerShell objects.

You can now see the same general information that netstat provided you by now; by default, you have information on the `OwningProcess` (the `-b` switch on netstat) and the `AppliedSetting` field, which relates to the network profile the connection is a part of.

Related:[How to Change Windows 10 Network Profiles the Easy Way](https://adamtheautomator.com/windows-10-change-public-network-to-private/)

> _Unlike netstat, the `Get-NetTCPConnection` cmdlet will now show listening UDP connections._

![Get-NetTCPConnection](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T152005.275.png)

_Get-NetTCPConnection_

3\. Pipe the output to `Select-Object` showing all properties. You’ll see PowerShell returns a lot more information that netstat did.

```powershell
Get-NetTCPConnection | Select-Object -Property *
```

![Pipe the output to Select-Object](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T152202.672.png)

Pipe the output to Select-Object

4\. Now, narrow down the output to just listening ports.

```powershell
Get-NetTCPConnection -State Listen
```

![narrow down the output ](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T152321.260.png)

narrow down the output

5\. Now, find the process names for the `OwningProcess` fields. To do that, run the [`Get-Process`](https://adamtheautomator.com/powershell-get-process/) cmdlet and provide the process ID as shown below.

```powershell
Get-Process -Id 692
```

![Get-Process cmdlet](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T152534.221.png)

Get-Process cmdlet

If you’d like to create another property for the process name, you could optionally use a [`Select-Object` calculated field](https://mcpmag.com/articles/2017/01/19/using-powershell-calculated-properties.aspx).

```powershell
Get-NetTCPConnection | Select-Object -Property *,@{'Name' = 'ProcessName';'Expression'={(Get-Process -Id $_.OwningProcess).Name}}
```

6\. Narrow down the states to a bit more by finding `Listening` _and_ `Established` states by defining the `State` parameter value as a comma-delimited list.

```powershell
Get-NetTCPConnection -State Listen,Established
```

7\. Finally, limit the connections down by the port the connection is connected to with the `RemotePort` parameter.

> _Use the `LocalPort` parameter to filter connections by local port._ `Get-NetTCPConnection -RemotePort 443`

```powershell
Get-NetTCPConnection -RemotePort 443
```

![RemotePort parameter](https://adamtheautomator.com/wp-content/uploads/2021/04/Untitled-2021-04-05T152835.540.png)

RemotePort parameter

## Conclusion

You have now seen how the Netstat utility and the `Get-NetTCPConnection` PowerShell cmdlet help you find local network connections.

Now that you can show the processes running on a server combine this with the [Test-NetConnection](https://adamtheautomator.com/test-netconnection/) PowerShell cmdlet to get an end-to-end view of connectivity between a client and server.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fnetstat-port%2F&text=How%20to%20Find%20Listening%20Ports%20with%20Netstat%20and%20PowerShell)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fnetstat-port%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fnetstat-port%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
