5th December 2024

What is Test-NetConnection Command and How to Use It?

Test-NetConnection is a PowerShell cmdlet that checks and then displays cookies about a network connection to another computer/server on the same network or a web server on the Internet.

How to Use Test-NetConnection?

The “Test-NetConnection” command will be used via PowerShell. The Test-NetConnection command has some features other than just pinging. You can see them below.

  • “Test-NetConnection” Command

When we use this command alone, what it does is PING a web beacon and display the result whether successful or not.

"Test-NetConnection" Command
“Test-NetConnection” Command

 

  • “-InformationLevel” Command

(Test-NetConnection -InformationLevelDetailed“) the command gives your local IP address. It also shows what your router’s IP address is.

"-InformationLevel" Command
“-InformationLevel” Command

 

  • “-Port” and “-ComputerName” Commands

You can check whether the relevant port of the opposite system is open by specifying the desired port number with the “-port” command. In other words, it is to provide port-based control.

An address can be specified using the “-ComputerName” command.

Test-NetConnection -port 80 -ComputerName "systemconf.com" -InformationLevel "Detailed"
"-Port" and "-ComputerName" Commands
“-Port” and “-ComputerName” Commands

 

  • -CommonTCPPort “port name”

You can also use the port name if you want. But you can only try the following port names.

  • SMB
  • HTTP
  • RDP
  • WinRK
-CommonTCPPort "port name"
-CommonTCPPort “port name”

 

  • -port command

Below you can see the shorter version of the same command. In other words, it is to provide port-based control.

Test-NetConnection systemconf.com -port 80
-port command
-port command

 

  • “ -InformationLevel Quiet” Command

The result section can be shortened further with the ” -InformationLevel Quiet” command. If the answer is “True”, it means the port is open, and “False” means the port is closed.

“ -InformationLevel Quiet” Command
“ -InformationLevel Quiet” Command

 

  • -TraceRoute Command

You can do a TraceRoute with Test-NetConnection to list all the network hops used to go to the target computer.

Test-NetConnection systemconf.com -TraceRoute
-TraceRoute Command
-TraceRoute Command

 

LEARN MORE  What is SCOM (System Center Operations Manager)?

Leave a Reply

Your email address will not be published. Required fields are marked *