How to determine what app is using a port

While it is sometimes easy to determine what app is using a port, it is not always the case. For example, if you are running a web app, and you want to know what app is using port 80, you can’t just look at the process list. You have to run a script to find the culprit. In the past this was a netstat command, but it can be simpler to use PowerShell.

Note: Update XXXX with your port number.

Get-Process -Id (Get-NetTCPConnection -LocalPort XXXX).OwningProcess