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
I dont understand how this works, can anybody help
LikeLike
Hi,
Test-NetConnection tests the TCP Connectivity to other hosts. You can run it local or remote. Hope this helps. Regards, P
LikeLike
Looking for all command let’s type .its useful and easy to apply in realtime
LikeLike
Hi Manju, If you are looking for all Network Commands in PowerShell type Get-Command -module NetTcpIp.
LikeLike