If you want to find out which process is listening on a specific TCP/UDP port, you can also use PowerShell for this in Windows. I find this easier than analyzing the output of netstat.
I also show this in a Video on YouTube.
For TCP: Get-NetTCPConnection
For TCP connections, there is the Get-NetTCPConnection cmdlet. However, it only returns the ID of the running process (the OwningProcess property), but we can resolve that using Get-Process. Manually, you would do it like this:
| |
But you can cleverly combine PowerShell cmdlets to turn them into a one-liner. Of course, there are various ways to shorten the code or customize it. Here are a few examples that all essentially do the same thing, but in different ways.
| |
The return value is a [System.Diagnostics.Process] object with various properties. At first glance, ProcessName is the most interesting.
However, you can also retrieve more information about the program on the hard drive by running Get-Process with the -FileVersionInfo parameter. This returns a [System.Diagnostics.FileVersionInfo] object instead.
| |
For UDP: Get-NetUDPEndpoint
A different cmdlet is required for UDP: Get-NetUDPEndpoint
In the standard output, the OwningProcess property isn’t shown for me, but it still exists.
| |
I’ll spare us the two-step manual query; instead, here are again a few more options for one-liners:
| |
As with the examples for TCP, Get-Process returns a [System.Diagnostics.Process] object for the process.
Once again you can add the -FileVersionInfo parameter to Get-Process to see the full path on the hard drive and other infos.
| |


