windows check com ports in use code example

Example 1: powershell see ports in use

See Ports in Use: 
Get-NetTCPConnection | where Localport -eq PORT_NUMBER | select Localport,OwningProcess

Kill Port In Use

*Set this command*
netstat -ano | findstr :PORT_NUMBER
*To find a ID Process look a exemple below*
TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       THIS IS ID PROCESS --->[12948]

*Kill IDProcess*
taskkill /PID IDPROCESS /F

Example 2: common ports

#Common Ports
20FTP (File Transfer Protocol) Data Transfer
21FTP (File Transfer Protocol) Command Control
22 - SFTP (SSH File Transfer Protocol)
22SSH (Secure Shell)
23 - Telnet - Remote login service, unencrypted text messages
25SMTP (Simple Mail Transfer Protocol) E-mail Routing, Sending email
53DNS (domain name service)
80HTTP (Hypertext Transfer Protocol) used in World Wide Web. "web server"
110POP3 (Post Office Protocol) used by e-mail clients to retrieve e-mail from a server
119 - NNTP (Network News Transfer Protocol)
123NTP (Network Time Protocol)
143IMAP (Internet Message Access Protocol) Management of Digital Mail)
163 - SNMP (Simple Network Management Protocol)
194 - IRC (Internet Relay Chat)
443HTTPS (HTTP Secure (HTTPS) HTTP over TLS/SSL). "secure web server"
465SMTPS (send secure email)
631CUPS (print server)
993IMAPS (secure email inbox)
995POP3 (secure email inbox)