Get-NetTCPConnection
Use Get-NetTCPConnection to list TCP connections and listening ports with the owning process id.
Documentation: Microsoft Learn — PowerShell module reference
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-NetTCPConnection [[-LocalAddress] <string[]>] [-LocalPort <UInt16[]>] [-RemoteAddress <String[]>] [-RemotePort <UInt16[]>] [-State <State[]>] [-OwningProcess <UInt32[]>] [-CimSession <CimSession[]>] [<CommonParameters>]- Stage 1Get-NetTCPConnection
-LocalAddress -LocalPort -RemoteAddress -RemotePort -State -OwningProcess -CimSession
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Get-NetTCPConnection -State Listen
Show reference output
Sample output · fictional data, shaped like the real thing
LocalAddress LocalPort OwningProcess ------------ --------- ------------- 10.20.30.41 51544 9184 10.20.30.41 51612 6620
Get-NetTCPConnection -LocalPort 443
Show reference output
Sample output · fictional data, shaped like the real thing
LocalAddress LocalPort RemoteAddress RemotePort State OwningProcess ------------ --------- -------------- ---------- ----------- ------------- 10.20.30.41 51544 13.107.42.14 443 Established 9184 10.20.30.41 51612 20.190.151.132 443 Established 6620
Get-NetTCPConnection -State Established
Show reference output
Sample output · fictional data, shaped like the real thing
Count Name ----- ---- 2 SampleA 1 SampleB
Parameters
Parameter definitions:
-LocalAddress-LocalPort-RemoteAddress-RemotePort-State-OwningProcess-CimSession
Practical use and troubleshooting
Practical scenario: Use Get-NetTCPConnection when you need to list TCP connections and listening ports with the owning process id. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A missing listener can mean the application is stopped or bound to another address. Inspect LocalAddress and LocalPort and check the owning process rather than changing the firewall first. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Test-NetConnection. Get-NetTCPConnection reads local TCP state; Test-NetConnection can test a remote TCP endpoint. A local Established connection is different from testing a new connection to a service. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Get-NetTCPConnection Use Get-NetTCPConnection to list TCP connections and listening ports with the owning process id.
Next: Get-ADGroupMember