check-port.ps1 193 B

123456
  1. $conn = Get-NetTCPConnection -LocalPort 3000 -ErrorAction SilentlyContinue
  2. if ($conn) {
  3. Write-Host "Port 3000 used by PID: $($conn.OwningProcess)"
  4. } else {
  5. Write-Host "Port 3000 is free"
  6. }