Even though PowerShell has been around since 2006, it's hard to start using some of the cmdlets after using CMD for ages. Sometimes, it actually just works as expected and you might not need anything else. With this post I hope to show some examples of why one should start considering PowerShell instead of using the command line tools.

I will only briefly talk about this, as each cmdlet could be their own entire post but these are the first examples I can think of that I actually use for daily troubleshooting.

Checking if a TCP port is reachable

If you work with Exchange and want to check if port 25 is reachable for SMTP, you might have used telnet. This works fine with SMTP because SMTP actually supports telnet. If you telnet to an Exchange server through port 25, you are actually able to send emails that way, so that's the reason why that test is feasible.

That doesn't mean that it's true for all TCP ports. Telnet will be able to show a result if the service is able to respond through Telnet. The much safer way to check a port is with the cmdlet Test-NetConnection (alias: tnc). This will show you if the port is open, as long as the port is open. If I'm troubleshooting SQL, I might want to check port 1433. We can do this by running the following line:

tnc sqlserver.domain.com -port 1433

Test-NetConnection has become one of my go-to troubleshooting tools now and is much more reliable than trying to Telnet to the port.

Tracerouting is much faster in PowerShell

Running tracert can be really, really slow. I think I might have gotten used to how slow it is, because when I first tried running the -traceroute switch on Test-NetConnection I was forever sold on using the PowerShell cmdlet.

One caveat, it still takes forever if ICMP is closed because then it has to time out. But in my testing it takes Test-NetConnection the same time to check all the hops and time out as tracert uses to get halfway through the jumps. That's not including actually timing out. Running a traceroute towards destruktive.one in PowerShell ended up taking 46 seconds while tracert used 3 minutes and 49 seconds.

tnc destruktive.one -traceroute

The ones that beats PowerShell, nslookup

Well, it kinda depends on what you want to do. If you're going to troubleshoot a bunch of domains, it's pretty easy to just type nslookup and then live inside of that tool until you're done. This is my preferred way of doing this, mainly because it's faster for me.

However, the more I use Resolve-DnsName the more used I am to the idea of using PowerShell. My preferences here might shift over time. Example of using PowerShell to resolve DNS:

Resolve-DnsName destruktive.one -Type A -Server 8.8.8.8

Summarized (TL/DR)

The more you use PowerShell, the more natural it feels to use it. Just the way the cmdlets are structured makes it easy to remember them, even though there are billions (might not be true) of them.

I suggest trying to limit yourself to PowerShell for a couple of days. I know that several years with the command line is hard to get by but PowerShell is here to stay and it is awesome, in my humble opinion.