Terminal Dojo
Help العربية Sign inGet started

Command library / Get-NetTCPConnection

Get-NetTCPConnection

PowerShellDraft — pending expert review3 practice missions

List TCP connections and listening ports

PowerShell's netstat, returning objects you can filter. Each connection has a LocalAddress and LocalPort, a RemoteAddress and RemotePort, a State (Listen, Established, TimeWait…) and an OwningProcess: the PID of the program behind it, which you can hand straight to Get-Process.

Practice Get-NetTCPConnection

Usage

Get-NetTCPConnection [-State <state>] [-LocalPort <int>] [-RemotePort <int>] [-RemoteAddress <ip>] [-OwningProcess <pid>]

Options and flags

Examples

Common mistakes

Get-NetTCPConnection -State Listening Get-NetTCPConnection -State Listen

The state is called Listen here, not LISTENING as netstat prints it.

Related commands

get-processtest-netconnectionnetstat