Discovering Active Network Connections with PowerShell

Abstract: Resolve network connectivity issues by identifying active TCP sessions and their responsible processes using Get-NetTCPConnection.

Created: 2026-09-04 by
Use the Get-NetTCPConnection cmdlet to identify active network sessions on your local machine or remote hosts. This command provides detailed information about established, listening, and closed connections, including local and remote addresses, ports, and the associated process ID. By piping the output to Format-Table or Select-Object, you can filter for specific states like ESTABLISHED or LISTENING to quickly diagnose connectivity issues or monitor resource usage in real-time.

Understanding Active Connections

When troubleshooting network issues or auditing system activity, knowing which processes are communicating over the network is essential. Windows PowerShell offers several cmdlets designed specifically for this purpose, with Get-NetTCPConnection being the most robust tool for inspecting TCP-based interactions. Unlike older tools such as netstat, these modern cmdlets return structured objects that are easier to manipulate programmatically.

An active connection typically refers to a socket pair where data is either flowing or ready to flow. These connections exist in various states defined by the Transmission Control Protocol (TCP). Common states include ESTABLISHED, indicating an active data transfer; LISTENING, where the system is waiting for incoming requests; and CLOSE_WAIT, which suggests a remote peer has initiated a closure but the local application hasn't finished closing its side. Identifying these states helps distinguish between healthy traffic and potential hangs or leaks.

Basic Usage of Get-NetTCPConnection

To get started, open PowerShell as an administrator if you need to view details for all users or system services. Running the command without parameters returns every TCP connection currently tracked by the operating system. This output includes columns for LocalAddress, LocalPort, RemoteAddress, RemotePort, State, and OwningProcess.

Get-NetTCPConnection

The raw output can be overwhelming due to the volume of background services connecting to cloud APIs or internal network shares. To make sense of this data, you should always pipe the results into formatting cmdlets. Using Format-Table allows you to select only the relevant columns for your investigation. For example, focusing on the state and remote address helps you see who is talking to whom without getting bogged down in technical port numbers.

Get-NetTCPConnection | Format-Table -Property LocalAddress, LocalPort, RemoteAddress, RemotePort, State

Filtering by Connection State

Often, you are only interested in connections that are actively transferring data. You can achieve this by using the -State parameter. This filters the results before they reach your console, improving performance when dealing with systems that have hundreds of open sockets. The most common states you will query are ESTABLISHED for active sessions and LISTENING for servers waiting for clients.

Get-NetTCPConnection -State Established

If you suspect a service is stuck in a half-open state, checking for CLOSE_WAIT or TIMED_WAIT can reveal applications that are failing to release resources properly. This is particularly useful when diagnosing memory leaks or unresponsive services that hold onto network handles indefinitely.

Identifying the Responsible Process

Knowing that a connection exists is only half the battle; you usually need to know which application is responsible for it. The OwningProcess property in the output contains the Process ID (PID) of the application holding the socket. However, PIDs alone are not very human-readable. To map these IDs to actual application names, you can join the network data with process information.

One effective method is to use Select-Object to expand the OwningProcess property and then look up the process name. Alternatively, you can create a custom object that includes the process name directly. This involves querying Get-Process for each unique PID found in the connection list. While this adds complexity to the script, it provides immediate clarity on which executable is generating the traffic.

Get-NetTCPConnection -State Established | 
    Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State, @{Name='ProcessName';Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}

This approach is invaluable when debugging unexpected network usage. For instance, if you see a high number of connections to a specific IP address, identifying the process allows you to determine if it is a legitimate update check or potentially malicious software communicating with a command-and-control server. This technique complements other networking tasks, such as testing open UDP ports on a specified IP address, by giving you context on what is actually using those ports.

Remote System Analysis

While local analysis is common, IT professionals often need to inspect the network status of remote servers. Get-NetTCPConnection supports the -ComputerName parameter, allowing you to run queries against other machines on the network. This requires appropriate permissions, typically administrative access, and may involve configuring WinRM (Windows Remote Management) or firewall rules to allow the query.

Get-NetTCPConnection -ComputerName "Server01" -State Listening

When querying remote systems, network latency can affect performance, especially if you are retrieving large amounts of data. It is best practice to filter strictly on the remote side by specifying states or filtering criteria whenever possible. This reduces the amount of data transferred back to your local workstation. Additionally, ensure that the remote host allows PowerShell remoting, as failures here are common in locked-down environments. If you encounter permission errors while trying to gather this data, you might find guidance in articles discussing changing permissions in Windows 10, as similar ACL issues can apply to remote management protocols.

Advanced Filtering and Automation

For more complex scenarios, you can combine Get-NetTCPConnection with other cmdlets to build comprehensive monitoring scripts. For example, you might want to alert when a specific port is occupied by an unknown process. You can achieve this by filtering the results based on LocalPort and then checking the process name against a whitelist of known applications.

Automation is key in large-scale environments. You can schedule these scripts to run periodically and log the results to a CSV file or a database. This historical data helps in trend analysis, showing how network usage evolves over time. If you are deploying these scripts via Task Scheduler, remember that background jobs may fail silently if not configured correctly. Troubleshooting these execution issues often requires checking the user context and working directory, a topic covered in guides about Powershell Script Not Running in Task Scheduler.

Frequently Asked Questions

Why does Get-NetTCPConnection show many connections I don't recognize?

Windows runs numerous background services and updates that maintain persistent connections to Microsoft servers and local network resources. Many of these are system-critical processes like Windows Update, telemetry services, or DNS cache managers. Unless a connection is to an external IP you do not trust, these are usually safe and expected behavior.

How can I close a specific active connection using PowerShell?

PowerShell does not have a direct cmdlet to terminate a network connection by ID. Instead, you must identify the OwningProcess and use Stop-Process to kill the application. Be cautious, as killing a critical system process can cause instability or data loss. Always verify the process name before termination.

Can I use this cmdlet to monitor UDP connections?

No, Get-NetTCPConnection only works for TCP sockets because TCP is a connection-oriented protocol with distinct states. UDP is connectionless and does not maintain session states like ESTABLISHED or LISTENING. For UDP, you would need to use different diagnostic tools or check the NetUdp table via Get-NetUDPEndpoint.

What permissions are required to run these commands?

You generally need Administrator privileges to view connections owned by other users or system services. Standard users can view their own connections but may see restricted information for global system processes. Running PowerShell as Administrator ensures you have full visibility into all network activity on the machine.

Is there a way to filter connections by a specific remote IP address?

Yes, you can use the Where-Object cmdlet to filter the output after retrieval. For example, Get-NetTCPConnection | Where-Object {$_.RemoteAddress -eq "192.168.1.10"} will show only connections to that specific IP. Note that the cmdlet itself does not have a built-in parameter for remote IP filtering, so post-processing is necessary.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More