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](https://www.systemconf.com/wp-content/uploads/2021/08/img_61250474bfa67.png)
-
“-InformationLevel” Command
(Test-NetConnection -InformationLevel “Detailed“) the command gives your local IP address. It also shows what your router’s IP address is.
!["-InformationLevel" Command](https://www.systemconf.com/wp-content/uploads/2021/08/img_61250457d4793.png)
-
“-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](https://www.systemconf.com/wp-content/uploads/2021/08/img_612503fc5f26b.png)
-
-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"](https://www.systemconf.com/wp-content/uploads/2021/08/img_612505e0d8ca0.png)
-
-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](https://www.systemconf.com/wp-content/uploads/2021/08/img_612503b20d157.png)
-
“ -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](https://www.systemconf.com/wp-content/uploads/2021/08/img_612504f2600bc.png)
-
-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](https://www.systemconf.com/wp-content/uploads/2021/08/img_612549e3a20e9.png)