How to check if a port is in use using powershell
If you are using PowerShell Core v6 and above use Test-Connection
>Test-Connection localhost -TcpPort 80
True
Use Get-NetTCPConnection
Get-NetTCPConnection | where Localport -eq 5000 | select Localport,OwningProcess
Localport OwningProcess
--------- -------------
5000 1684