Written by 5:28 pm Microsoft, Microsoft Azure, PowerShell, Virtualization, Windows, Windows Server • 8 Comments

SuperPing – PowerShell Test-NetConnection

Test-NetConnection PowerShell Portscan

With Windows 8.1 and Windows Server 2012, R2 Microsoft released PowerShell v4 with new PowerShell modules and new PowerShell cmdlets. One of them is the new Test-NetConnection cmdlet, which does replace some simple network tools like Ping, Traceroute, port scanner, and more.

First, if you just run Test-NetConnection, this will check a Microsoft edge server and will tell you if your internet is working or not.

PowerShell Test-NetConnection

You can also ping other servers.

Test-NetConnection Ping

If we have a closer look at this cmdlet, we can see that we can do much more.

get-help get-testnetconnection

What we can do is something like a port scan. In this example, I check if the RDP port is open on my webserver. Which is hopefully not ;-)

Test-NetConnection thomasmaurer.ch -CommonTCPPort RDP

Test-NetConnection PowerShell Portscan

You can also check for not so common ports by using the -Port parameter and entering the port number.
Another thing you could do would be a simple traceroute.

Test-NetConnection thomasmaurer.ch -TraceRoute

Test-NetConnection PowerShell Traceroute

If you want to do a ping -t you could use the following command

while ($true) {Test-NetConnection -InformationLevel Quiet}

Ping -t with PowerShell

I hope this helps you a little :)

Find more networking PowerShell cmdlets in my PowerShell Networking cheatsheet.

Tags: , , , , , , , , , Last modified: June 29, 2020
Close Search Window
Close