Skip to content
Caleb SmithCyberSecurityWithSmitti
Browse PowerShell example contentPowerShell example

06 · Get-NetTCPConnection: inspect active TCP endpoints

Inspect currently established TCP endpoints and their owning process IDs.

How to use it

Use the owning process ID as a lead for a separate process lookup.

Platform and permissions

Windows NetTCPIP module; rights and platform affect availability.

What changes / what is read

Reads local TCP state; it does not scan or contact remote endpoints.

Scope and interpretation

A point-in-time TCP list excludes UDP and completed sessions. An unfamiliar address alone is not a malicious verdict.

Practice task

List evidence you would seek before attributing a connection.

Reference

Microsoft documentation. Review the documentation for your installed version and use only an authorised learning or investigation environment.

This is personal educational material. Review the complete code and your signing policy before use. PowerShell code is displayed and downloaded as text; WordPress does not run it. Collection caps limit rows/files, not every provider’s wall-clock execution time.

PowerShell · PowerShell 5.1+ syntax target; Windows collectors require the stated Windows modules. Full Windows acceptance testing remains required.Download .ps1
#requires -Version 5.1
Get-NetTCPConnection -State Established |
    Select-Object -First 50 LocalAddress, LocalPort, RemoteAddress, RemotePort, OwningProcess

Example code is displayed as text. Review it and test in your own lab before use.