As several blogposts and Stackoverflow answers suggest, it is trivial to get this information via a combination of `get-process` and `Get-NetTCPConnection` commandlets. It is possible to execute these commands via .net code, parse the output and retrieve the information.

Is it not possible to get the port number a process is listening on in pure .net code using just the .net libraries? `System.Diagnostics.Process.GetProcesByName` returns a ton of information via the `Process` object, except for the port the process is listening on.

Any leads highly appreciated.