PowerShell - Testing network connectivity and port accessibility
2 min read · Updated 22 January 2025
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 connectivityTest-connection -ComputerName www.google.com
# Set number of pings (default 4)Test-connection -ComputerName www.google.com -Count 1
# Only return a boolean valueTest-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 WinRMTest-connection -ComputerName www.google.com -Source PC-1,PC-2# Or by providing credentialsTest-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 informationTest-NetConnection -ComputerName www.google.com -CommonTCPPort HTTP -InformationLevel Detailed
# Only return a Boolean valueTest-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 443Related links
- PowerShell
PowerShell - Simply send objects to different variables
PowerShell - Tip - Simply send objects to different variables
1 min read
- PowerShell
PowerShell - Display network connections (equivalent to netstat)
Display network connections (listening ports, active connections...)
2 min read
- PowerShell
PowerShell - Testing name resolution (equivalent to nslookup)
PowerShell commands to test name resolution (equivalent to nslookup)
2 min read
- PowerShell
PowerShell - View and manage DNS configuration of network interfaces
PowerShell commands to display and manage DNS configuration of network interfaces
4 min read
- PowerShell
PowerShell - Managing IP configuration of network interfaces
PowerShell commands to view and modify the IP configuration of network interfaces
4 min read
- PowerShell
PowerShell - Managing the status and configuration of network interfaces
PowerShell commands to view and modify the status and configuration of network interfaces (disable IPv6, enable/disable an interface)
4 min read