Background
Dealing with them insomnia nights and you run into a trouble.
And, you say I have other problems, I will come back and deal with this in the morning.
Get-NetTCPConnection
Base
To get a quick list of TCP Connections, you issue “Get-NetTCPConnection”
Command
Sample
powershell -Command "Get-NetTCPConnection"
Output
Image
SQL Server ( TCP Port 1433 )
To get a quick list of SQL Server Connections, you issue “Get-NetTCPConnection -RemotePort 1433”
Command
Sample
powershell -Command "Get-NetTCPConnection -RemotePort 1433"
Output
Image
Unknown Port ( TCP Port 14330 )
But, here comes a typo you went thirsting for 1433, but mistakenly entered 14330.
Command
Sample
powershell -Command "Get-NetTCPConnection -RemotePort 14330"
Output
Image
Text
>powershell -Command "Get-NetTCPConnection -RemotePort 14330" Get-NetTCPConnection : No MSFT_NetTCPConnection objects found with property 'RemotePort' equal to '14330'. Verify the value of the property and retry. At line:1 char:1 + Get-NetTCPConnection -RemotePort 14330 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (14330:UInt16) [Get-NetTCPConnection], CimJobException + FullyQualifiedErrorId : CmdletizationQuery_NotFound_RemotePort,Get-NetTCPConnection >
Unknown Port ( TCP Port 14330 ) – Workaround
In case you are not in the mood for big phrased errors.
Or simply walking a set of network ports, there is a gracious workaround.
Just suffix your command with “-ErrorAction SilentlyContinue“.
Command
Sample
powershell -Command "Get-NetTCPConnection -RemotePort 14330 -ErrorAction SilentlyContinue"
Output
Image
Text
Referenced Work
- Microsoft
- Docs > Windows > PowerShell > Reference > NetTCPIP
- Get-NetTCPConnection
Link
- Get-NetTCPConnection
- Docs > Windows > PowerShell > Reference > NetTCPIP