PowerShell: Find Which Process Is Listening on a Port

Need to identify which process owns a specific listening port - for troubleshooting a port conflict or investigating unfamiliar network activity? This one-liner combines port and process info into one readable table.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

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

Example Output:

LocalAddress  LocalPort ProcessName
------------  --------- -----------
::                49664 lsass
0.0.0.0             445 System
0.0.0.0             135 svchost
127.0.0.1         51234 Code
0.0.0.0           16992 LMS
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Get-NetTCPConnection -State Listen returns all listening ports, same as the previous open ports article - but this only shows a numeric OwningProcess ID, not a readable process name on its own.
  • The calculated property @{Name="ProcessName"; Expression={...}} looks up that process ID for each port and pulls back its actual name, combining two separate pieces of information into a single table.
  • Inside the expression, $.OwningProcess refers to the process ID of the current port being processed, and (Get-Process -Id $.OwningProcess).ProcessName looks up that specific process and extracts just its name.
  • This turns an otherwise meaningless number (OwningProcess) into something immediately useful - like seeing that port 16992 belongs to LMS (Intel Management Engine), rather than just a process ID you'd have to look up separately.