I’ve been using PowerShell for about 3 years now, but mostly in script format. Most of my previous experience with PowerShell revolved around managing Exchange and Active Directory. However, I never really “got” PowerShell and it’s capabilities before. I was familiar with VB script and Batch scripting from my time creating SCCM packages. At the time, I figured anything I could do with Powershell was easier to do with SCCM, VBScripts, or 3rd party tools. I feel like I judged PowerShell unfairly back then and I regret not spending the time with this language that it deserved.
Over the years Powershell has been pushed more into every nook and cranny of Windows. I dare say that today, the GUI’s no longer provide a way to work at scale or work effectively. Exchange Admins are already familiar with this, but how many of you still use Vmware’s vSphere Client because the web interface… kind of sucks?
A few months ago I decided to try to using the PowerShell console for all of my administrative tasks at work. Since I still had to get work done, I would from time to time stray back to using GUI tools, but would come back later and figure out how I could have done the task via Powershell. Still, something over time started to click. I started understanding how the object based system was so closely related to the way the Windows Operating System works. Things I used to use SCCM and WMI mining for now started becoming available at my fingertips in easy to understand commands.
I figured I should share a few things that helped me use PowerShell more effectively and some links to some free training that helped me out as well.
Get-Help and Get-Help Often
Don’t get me wrong, Google works pretty well to find scripts and find solutions to common problems in PowerShell. It’s pretty easy to find a script that will do pretty much anything that you may want from a few minutes of Googling. But next time your find a cmdlet you don’t recognize or even just to learn more about the cmdlets you already use, try using the get-help system on those cmdlets. There’s a wealth of information about how these cmdlets can be used and customized to do more. I particularly like the -ShowWindow and -Online flags to get an easy view of the documentation behind a cmdlet.
You can also use this cmdlet to “discover” other cmdlets. For example, if I was wondering what I can do with X.509 certificates in Powershell, I could just type get-help “cert” and get a bunch of cool tools I could leverage to manage certificates. Get-command *commandname* is probably a better way of doing this, but both seem to do the job just fine when you’re starting out. Also! You learn what the cmdlet is doing rather than just copy pasting code from the internet.
By the way, there’s an awesome video done by Jeffrey Snover and Don Jones on this idea of PowerShell discoverability. I highly recommend checking it out.
Don’t wait for the login screen try enter-pssession instead.
Enter-PSSession “ComputerName” is what I started doing when I felt like I wanted to interact with a server, but didn’t want to log in. What this effectively does is give you a remote PowerShell session on the target machine. This is pretty great when you need to parse the local registry or other local PSProviders for information. A better way to do this is to use invoke-command, but its a good way to get a feel for what’s going on.
Powershell.org has an awesome book called the Secrets of Powershell Remoting. Great information on how remoting works, how to use it properly, and some helpful information for your IT security officers in case WinRM isn’t already turned on your servers.
Train and Practice!
There’s so much free training out there and great resources that are free! If you’re just starting out, go to Microsoft’s Virtual Academy and take their Powershell 3.0 jump start.
Powershell.org has a large collection of free e-books and videos. I would try and take advantage of these free resources while they are around.
If you’re into automation and want to learn to start making powerful tools to empower yourself and your colleagues, check out Don Jones’ Toolmaking series. So many moments in his videos where things will just start to “click”.
Finally, if you’re running a Windows 10 machine with decent specs, you should know that you can create your own virtual lab using Hyper-V. Check out the Microsoft Doc on how to get Hyper-V set up on Windows 10 for more information.