Powershell - Testing network connectivity and port accessibility

To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make 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