List listening TCP connections and owning processes
Build a paste-ready command, then review its compatibility and effects before running it.
Get-NetTCPConnection -State Listen | Sort-Object LocalPortread-onlyno known side effects Compatibility
WindowsVerified for Windows using powershell syntax.
Operational knowledgereview due 2027-01-19
RequirementsGet-NetTCPConnectionGet-NetTCPConnection must be installed and available on PATH.
Version supportGet-NetTCPConnection Current supported releasesVerified for windows using powershell syntax; consult compatibility notes for platform-specific differences.
Expected signalsLocalAddress LocalPort RemoteAddress RemotePort State OwningProcessRepresentative successful output; values vary with the selected target and system state.
Known errorsGet-NetTCPConnection: command not foundGet-NetTCPConnection is missing or is not available on PATH.
VerifyGet-NetTCPConnection -State Listen | Sort-Object LocalPortThe output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01Get-NetTCPConnectionCommandRuns the Get-NetTCPConnection stage of this one-liner.
02-StateOptionConfigures Get-NetTCPConnection with the -State option.
03ListenArgumentPasses Listen to Get-NetTCPConnection.
04|PipelinePasses the output on the left to the command on the right.
05Sort-ObjectCommandRuns the Sort-Object stage of this one-liner.
06LocalPortArgumentPasses LocalPort to Sort-Object.
Example input
Get-NetTCPConnection -State Listen | Sort-Object LocalPort
Example output
LocalAddress LocalPort RemoteAddress RemotePort State OwningProcess
------------ --------- ------------- ---------- ----- -------------
0.0.0.0 80 0.0.0.0 0 Listen 4312
0.0.0.0 443 0.0.0.0 0 Listen 4312
127.0.0.1 3000 0.0.0.0 0 Listen 11244
Illustrative output — exact values vary by system and data.
Runbooks
Official sources