The more I am playing with it, the more I like it: Test-NetConnection. Test-NetConnection views information of a connection. What can we do with it?
Ping
If the computername was not specified, the default value is internetbeacon.msedge.net.
Test-NetConnection
Let´s specify an address for the remote host.
Happy to see that sid-500.com is responding much faster than the beacon thing. 😉
Test HTTP Connections
Is it possbile to establish a connection to sid-500.com with HTTP?
Test-NetConnection www.sid-500.com -CommonTCPPort HTTP
Yes, it is. And what about HTTPS?
Test-NetConnection www.sid-500.com -Port 443
Test RDP Connections
Well, my blog is working. Hopefully my blog cannot be reached via Remote Desktop (RDP). Good to see that it is not so.
Test-NetConnection www.sid-500.com -CommonTCPPort RDP
Running Test-Connection with tracert / traceroute
Traceroute traces the route of packets to a destination host. You can do the same with Test-NetConnection.
Test-NetConnection www.sid-500.com -TraceRoute
Running in Quiet Mode
Be Quiet. Show me only whether the host is reachable or not.
Test-NetConnection www.sid-500.com -InformationLevel Quiet
Running in Detailed Mode
To get more out of Test-Connection run it in Detailed Mode. Pay attention to the additional information about DNS Name Resolution and the Next Hop Address.
Test-NetConnection www.sid-500.com -InformationLevel Detailed
Remote Computers
What about Remote Computers? Can client001 establish a connection to dc01 via DNS? No need for logging on client001. Simply run a remote command:
Invoke-Command -ComputerName client001 {Test-NetConnection dc01 -Port 53 -InformationLevel Quiet}
Yes, client001 can establish a connection to dc01 via DNS.
Conclusion
Hope this is helpful. The “smaller” version is Test-Connection: The modern version of ping: Test-Connection.
Or find out the IP-Address of the default gateway by reading the routing table: PowerShell: Testing the connectivity to the Default Gateway on localhost and Remote Hosts by reading the Routing Table
Categories: PowerShell
Hello Patrick,
How can I get Test-netConnection for failed connection to email only when TCPTestSucceded = False.
I tried -eq & – ne options but having no luck
Bruce
LikeLike