PowerShell - Testing network connectivity and port accessibility

2 min read · Updated 22 January 2025

Did this guide help you? You can support me by subscribing to the channel, sharing it, disabling your ad blocker or making a donation. Thank you!

Hello,

A new article with PowerShell commands for testing network connectivity (equivalent to ping) and port access (which can also be done with telnet, but this command is no longer available natively).

# Check network connectivity
Test-connection -ComputerName www.google.com
# Set number of pings (default 4)
Test-connection -ComputerName www.google.com -Count 1
# Only return a boolean value
Test-connection -ComputerName www.google.com -Quiet
# Ask other stations to ping the destination
# Eliminates the need to connect to remote computers to start pinging, allowing you to test from other sources
# Requires WinRM to be configured on remote hosts and an account authorized to use WinRM
Test-connection -ComputerName www.google.com -Source PC-1,PC-2
# Or by providing credentials
Test-connection -ComputerName www.google.com -Source PC-1,PC-2 -Credential (Get-Credential)
# Test accessibility of common ports (SMB, HTTP, RDP, ping)
Test-NetConnection -ComputerName www.google.com -CommonTCPPort HTTP
# Display more information
Test-NetConnection -ComputerName www.google.com -CommonTCPPort HTTP -InformationLevel Detailed
# Only return a Boolean value
Test-NetConnection -ComputerName www.google.com -CommonTCPPort HTTP -InformationLevel quiet
# Test port accessibility (you can also use the -InformationLevel parameter)
Test-NetConnection -ComputerName www.google.com -Port 443

Related links