PowerShell, It’s Not Just for Server Jockeys

powershell tools

A long time ago in what almost seems like another galaxy, I was a server jockey. I was doing Linux before Linux was cool. BASH and Perl were my go to tools. Fast forward to now and the Windows server guys have finally found the joy of the shell script through PowerShell.

PowerShell isn’t just for the server guys though. I’m finding more and more uses for PowerShell to help me in my day to day work in networking. One of the first tools that I’ve come to depend on is the powershell commandlet Enter-PSSession. This works like psexec.exe, but isn’t usually blocked by AV like psexec.exe is now. Unlike psexec.exe it gives you a fully interactive shell on the remote computer. From there you can run ping, tracert and other cli tools as if you were physically on the computer. If you’ve ever had a ticket where you just need to run a few pings or a tracert to start troubleshooting but the user is unavailable or won’t let you remote control the computer, you’ll see the value in this ability.

Enter-PSSession

Another powershell commandlet that I use with the Enter-PSSession commandlet is the alias wget. While not really wget like you would find in Linux, it serves the same purpose. Typing wget and then a URL will get you a lot of information about the URL. You can use (wget http://www.contoso.com).content to output only the HTML or (wget http://www.contoso.com).rawcontent to output the HTTP headers as well. I like to use this with the site https://api.ipify.org which simply returns the IP address of the host as seen by the outside world. This is great for determining if NAT is working or if traffic is going out a different egress.

Animated GIF demo of using Enter-PSSession to run the wget powershell alias on a remote PC.
Example of using Enter-PSSession to run the PowerShell alias wget on a remote PC.

Driver Versions

Another useful powershell snippet is one that gives you the versions of drivers installed on a computer. I find this useful when troubleshooting client network issues, especially wireless, to compare with known version issues.

Get-WmiObject Win32_PnPSignedDriver| select devicename, driverversion | where {$_.devicename -like "*net*"}
Animated GIF showing Powershell script to get a listing of drivers and versions on a windows machine. This example filters down to drivers with net in the name.
Example of using PowerShell to interrogate a PC to report it’s drivers and driver versions.

Summary

Although Ansible, Python and such are the big automation buzz, PowerShell definitely has it’s place. Network Engineers should make sure to familiarize themselves with PowerShell. I will continue to make posts as I find useful snippets to share.