6

Use Test-NetConnection in PowerShell to See If A Port Is Open

 3 years ago
source link: https://thomasrayner.ca/use-test-netconnection-in-powershell-to-see-if-a-port-is-open/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Use Test-NetConnection in PowerShell to See If A Port Is Open

The days of using ping.exe to see if a host is up or down are over. Your network probably shouldn’t allow ICMP to just fly around unaddressed, and your hosts probably shouldn’t return ICMP echo request (ping) messages either. So how do I know if a host is up or not?

Well, it involves knowing about what your host actually does. What ports are supposed to be open? Once you know that, you can use Test-NetConnection in PowerShell to check if the port is open and responding on the host you’re interested in.

PS> Test-NetConnection -ComputerName $computerName -Port 3389


ComputerName     : <snip - name of the computer I'm testing>
RemoteAddress    : <snip - IP address of the computer I'm testing>
RemotePort       : 3389
InterfaceAlias   : Ethernet
SourceAddress    : <snip - my IP address>
TcpTestSucceeded : True

Here I just checked if port 3389 (for RDP) is open or not. Looks like it is.

Written on July 26, 2017

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK