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 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 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, and other 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 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 that I use with the Enter-PSSession is the alias . While not really you would find in Linux, it serves the same purpose. Typing and then a URL will get you a lot of information about the URL. You can use ( http://www.contoso.com).content to output only the HTML or ( 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.

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*"}
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.