Note: Article Written on Server 2012 R2 Preview Build, functionality may change when released.
I have been waiting years for a good replacement for what Telnet and Ping provide me. I am thrilled to announce today I discovered a legitimate replacement has come down the line! Recently Microsoft released the Preview of Server 2012 R2 and Windows 8.1. Packaged with those is PowerShell Version 4. I have not had a chance to do a deep dive into it yet, however I have found out that there is a really cool new cmdlet called Test-NetConnection.
Test-NetConnection does exactly what it sounds like. It is going to by default (No Parameters) perform a ping on internetbeacon.msedge.net, which at the time of writing this is failing. Now this tool does a lot more than just ping, it also adds traceroute, and connection attempts to specified ports. Below is a snapshot of the Syntex for this cmdlet.
Lets say we have an server running that allows Remote Desktop Connection, we know it exists but for some reason connections are not working. Well once you verified RDP is enabled through the console the next step might be verifying you can get through firewall. The way I normally approach this is by using “telnet server.name 3389″ well the problem with this is that the server may not have the telnet client installed, that was an optional install starting in Server 2008.
I was really hoping for something in PowerShell v3, but sadly nothing showed up. However tonight I found out thanks to a Microsoft employee presenting named Bob Roudebush that this now exist! So instead of installing telnet I can simply use the PowerShell cmdlet “Test-NetConnection server.name -Port 3389″. Please note that you can also use “Test-NetConnection server.name -CommonTCPPort RDP”
Lets not stop at something that simple now, because PowerShell is all about automating. So lets try to do something crazy. I know on my virtual lab at home I have a few VM’s running so lets verify RDP is open on all of these servers. Well luckily for me, most of them are joined to an Active Directory so lets do some magic.
(Get-ADComputer -LDAPFilter "(name=griffin*)").DNSHostName | Test-NetConnection -Port 3389
The above command will pull every computer from Active Directory (Using the Active Directory PowerShell Tools) and pipe it to Test-NetConnection which specifies the RDP port.
I am hoping over the next few weeks that I can dig into PowerShell v4, Server 2012 R2 and Windows 8.1 so that I can provide more information on these upcoming products and the excellent new features that are a part of them.