If you’d like to test whether a specific computer or URL is online, for decades ping requests (ICMP) have been used. In recent times, many servers and firewalls turn off ICMP to reduce attack surfaces. Test-NetConnection by default uses ICMP, so it fails on computers that do not respond to ICMP:

PS> Test-NetConnection -ComputerName microsoft.com 
WARNING: Ping to failed with status: TimedOut
WARNING: Ping to failed with status: TimedOut
WARNING: Ping to failed with status: TimedOut
WARNING: Ping to failed with status: TimedOut
WARNING: Ping to failed with status: TimedOut

ComputerName           : microsoft.com
RemoteAddress          :
InterfaceAlias         : Ethernet 4
SourceAddress          :
PingSucceeded          : False
PingReplyDetails (RTT) : 0 ms 

There is another test built into Test-NetConnection that computers cannot avoid: a port test. Ports provide access to specific services, so a port must be available for any public service. For webservers, you could use port 80, for example:

PS> Test-NetConnection -ComputerName microsoft.com -Port 80

ComputerName     : microsoft.com
RemoteAddress    :
RemotePort       : 80
InterfaceAlias   : Ethernet 4
SourceAddress    :
TcpTestSucceeded : True

Here is a list of commonly used ports:
HTTP: Port 80
HTTPS: Port 443
FTP: Port 21
FTPS/SSH: Port 22
TELNET: Port 23
POP3: Port 110
POP3 SSL: Port 995
IMAP: Port 143
IMAP SSL: Port 993
WMI: Port 135
RDP: Port 3389
DNS: Port 53
DHCP: Port 67, 68
SMB/NetBIOS: 139
NetBIOS over TCP: 445
PowerShell Remoting: 5985
PowerShell Remoting HTTPS: 5986

You are a PowerShell Professional, passionate about improving your code and skills? You take security seriously and are always looking for the latest advice and guidance to make your code more secure and faster? You’d love to connect to the vibrant PowerShell community and get in touch with other PowerShell Professionals to share tricks and experience? Then PowerShell Conference EU 2020 might be just the right place for you: https://psconf.eu (June 2-5, 2020 in Hanover, Germany).

It’s a unique mixture of classic conference with three parallel tracks filled with fast-paced PowerShell presentations, and advanced learning class with live discussions, Q&A and plenty of networking.

Secure your seat while they last: https://psconf.eu/register.html. Help build the agenda and make this “your” event by submitting hypothetical sessions you’d like to hear: https://powershell.one/psconfeu/psconf.eu-2020/reverse-cfp. And if you’d like to present yourself and join the psconf.eu speakers’ team, submit proposals: https://sessionize.com/psconfeu/.

Twitter This Tip! ReTweet this Tip!