Is there a way in powershell to check if a given port is in use or not?
In order to ping a specific port using Powershell, you have to use the “Test-NetConnection” command followed by the IP address and the port number to be pinged.
The netstat command produces tab-delimited, fixed-width tables. The following example converts the active connections that list active TCP connections as well as listening TCP and UDP ports to an object.
You can use netstat command to list the tcp port, if 443 port is listed there and state is established means 443 is open for outbound communication.
Use Get-NetTCPConnection
Get-NetTCPConnection | where Localport -eq 5000 | select Localport,OwningProcess
Localport OwningProcess
--------- -------------
5000 1684
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With