Get NetTCPConnection - PowerShell


The Get-NetTCPConnection cmdlet retrieves information about active TCP connections on the local computer. It provides detailed statistics and properties for each established connection, allowing administrators and network professionals to monitor and troubleshoot network traffic.


Get-NetTCPConnection [-ComputerName <String[]>] [-State <NetTCPConnectionState>] [-OwningProcess <String>] [[-Protocol <String>] | [-Port <Int32[]>]] [-IncludeProcessInfo] [-IncludeRemoteInfo] [[-OutputFile <String>] | [-OutFile <String>]]


  • -ComputerName: Specifies the remote computer to retrieve connections from.
  • -State: Filters connections based on their state. Valid options are: Established, Listen, CloseWait, TimeWait, DeleteWait, and Closing.
  • -OwningProcess: Displays only connections owned by a specific process.
  • -Protocol: Filters connections based on their protocol.
  • -Port: Filters connections based on their port number.
  • -IncludeProcessInfo: Includes process information in the output.
  • -IncludeRemoteInfo: Includes remote endpoint information in the output.
  • -OutputFile: Saves the output to a specified file.


Example 1: List established TCP connections


Example 2: Filter connections by state

Get-NetTCPConnection -State Established

Example 3: Filter connections by port and protocol

Get-NetTCPConnection -Port 80 -Protocol TCP

Example 4: Monitor TCP connections over time

while ($true) {
  $connections = Get-NetTCPConnection -IncludeProcessInfo
  Write-Host "Connections at $(Get-Date):"
  $connections | Format-List -Property Source, Destination, State, ProcessName
  Start-Sleep -Seconds 10

Common Issues

  • If no -ComputerName is specified, the command will retrieve connections from the local computer only.
  • Filtering by port or protocol may return connections in multiple states.
  • By default, remote endpoint information is not included in the output. To display remote endpoints, use the -IncludeRemoteInfo parameter.


Get-NetTCPConnection can be integrated with other PowerShell commands for advanced tasks. For example, you can use Format-Table to customize the output format, or pipe the output to Export-Csv to save it to a file.

  • Get-NetUDPConnection
  • Get-NetAdapter
  • Test-NetConnection