Three useful PowerShell commands for Windows network troubleshooting are Test-Connection, Test-NetConnection, and Resolve-DnsName. They answer different questions: can the host respond to an ICMP probe, can a specific TCP service be reached, and what does DNS return for a name? Using them in that order is helpful in some incidents, but the right starting point depends on the symptom.
Scope matters: Test-Connection is available in Windows PowerShell and modern PowerShell, although its parameter sets differ by version. Test-NetConnection belongs to the Windows NetTCPIP module, and Resolve-DnsName to the Windows DnsClient module. Neither Windows module should be assumed available on an arbitrary macOS or Linux installation of PowerShell.
1. Test-Connection: start with IP reachability
Test-Connection sends ICMP echo requests and can return structured results suitable for scripts. In supported PowerShell versions a simple positional invocation is:
Test-Connection example.com -Count 2
Run it against a host you administer or are authorized to test. A successful reply suggests that the remote system or an intermediate device responded to the probe. It does not prove that the web application, its authentication flow or a particular TCP port is working. Likewise, a timeout does not prove the host is offline: firewalls, network policies or devices may block or rate-limit ICMP.
In PowerShell 7, Test-Connection also has a TCP-port test parameter set, including -TcpPort. That parameter is not a universal substitute for Windows PowerShell 5.1 syntax. Check your installed version with $PSVersionTable.PSVersion and the available parameters with Get-Help Test-Connection -Full before reusing scripts from another environment.
2. Test-NetConnection: test a specific service port on Windows
Test-NetConnection can show Windows route and connection diagnostics and perform a TCP connection attempt. This example checks whether an HTTPS port is reachable:
Test-NetConnection -ComputerName example.com -Port 443
Review TcpTestSucceeded and the resolved address. A successful TCP handshake is narrower than a successful application request: TLS certificate validation, reverse-proxy routing, user authorization and the actual HTTP response may still fail.
For additional route or interface details on Windows, use an appropriate -InformationLevel Detailed invocation. The exact fields depend on the command’s parameter set and the available network interface information. Do not infer that all intermediate firewalls are healthy solely because one endpoint accepts a TCP connection.
3. Resolve-DnsName: examine the name-resolution answer
If the hostname resolves to the wrong address—or does not resolve at all—testing ports against it may lead you to the wrong system. Resolve-DnsName queries DNS and can select a specific record type:
Resolve-DnsName -Name example.com -Type A
Resolve-DnsName -Name example.com -Type AAAA
The A query requests IPv4-address records, while AAAA requests IPv6-address records. For troubleshooting split-horizon DNS or a recent record change, compare the output from the intended resolver with the output of another resolver you are authorized to query. Check record TTL, local name-resolution policy and whether a VPN changes the DNS servers in use. Do not confuse a DNS lookup result with proof that the returned service is reachable.
A practical decision sequence
| Symptom | First useful check | What the result does not establish |
|---|---|---|
| The hostname returns the wrong or no IP address | Resolve-DnsName for A/AAAA and the intended DNS server |
Whether the server or application is healthy |
| The IP address is known but basic network connectivity is uncertain | Test-Connection to the IP address |
Whether ICMP is permitted or a TCP service is available |
| The website resolves but the service appears unavailable | Test-NetConnection to TCP port 443 on Windows |
Whether TLS or application-level requests will succeed |
| One network works but the VPN or branch network does not | Compare DNS answers, interfaces, routes and policy from each location | Where the issue originates without tracing the actual path |
Walk through a failed web connection without guessing
- Record the affected URL, time, client subnet and whether the issue occurs for other users.
- Run
Resolve-DnsNameagainst the hostname. Confirm the expected record type and IP address. - Test the resolved IP and note whether ICMP is deliberately blocked. Use the site’s failed-ping troubleshooting guide for common reasons an echo request gets no reply.
- On Windows, run
Test-NetConnectionagainst the actual service port. Note the interface and source address if the result is unexpected. - If the TCP connection succeeds but the application still fails, inspect the TLS negotiation, HTTP status, reverse-proxy and application logs. These are separate checks, not additional uses of ping.
- Compare results from one known-good client and one affected client before changing DNS, routing or firewall policy.
Check the command reference for your environment
Microsoft documents Test-Connection in PowerShell 7, Test-NetConnection on Windows, and Resolve-DnsName on Windows. Use these versioned references instead of copying a flag from a different PowerShell release or operating system.
Takeaway: ICMP reachability, TCP service connectivity, and DNS resolution are three different tests. Combine the result of each with the actual application symptom; no single successful command is a complete network-health certificate.