The PowerShell Learning Experience
People often ask me about the book I co-wrote with Don Jones years ago, Learn Windows PowerShell in a Month of Lunches. Because the book was published in 2016 and uses a version of Windows PowerShell that you wouldn’t want to run in production today, the question comes down to relevance. Or, to put it bluntly, “Is this book outdated?”
Don and I focused on the question of relevance as we revised this edition. Over the years, the PowerShell community has passionately endorsed this book series as the go-to reference for PowerShell absolute beginners. Reading no single book, YouTube video, or Pluralsight course will teach you everything about PowerShell, and of course, you need to start with fundamentals. That is the direction Don and I took in the book. Assuming you stick with the chapter a day theme at the end of the month, you should know enough PowerShell to accomplish basic tasks from a PowerShell prompt.
Here’s the critical part and the answer to the relevant question. When we revised the book, we made a conscious effort to remove references to specific PowerShell versions. And that’s because beginning with PowerShell 3.0, the fundamentals haven’t changed. The idea of cmdlets writing objects to the pipeline hasn’t changed over the years. If you learned how to use operators in PowerShell 3.0, you didn’t have to re-learn how to use operators in PowerShell 7. Sure, there are likely new operators to learn, but that isn’t necessarily part of learning the PowerShell language and paradigm. That is a version-specific task.
Focus on Concepts
Learning PowerShell is not about memorizing what to type to achieve a specific result. It should be about learning the concepts and techniques behind PowerShell. That’s what the Month of Lunches books are all about; learning to use PowerShell effectively at a command prompt. The goal isn’t to teach you how to use Get-Service
But instead how to find the command in the first place. How to discover how to use it. Once you understand how to use Get-Service
in a PowerShell expression, you should be able to extend that knowledge a command like Get-VM
or Get-ADUser
.
I’m assuming that many of you reading this have moved beyond the PowerShell beginner stage. I’m also thinking most of you have probably been using PowerShell through several versions. You probably learned how to write PowerShell like this at the beginning of your education.
$s = Get-Service | Where-Object {$_.Status -eq 'running'}
Write-Host "Found $($s.count) running services" -ForegroundColor Green
$s[0,-1]
You had to learn about filtering, variables, and arrays. How much has that knowledge changed today? Once you understand these basics, it shouldn’t be that much harder to write something like this:
$h = Get-ChildItem c:\work -file | Where-Object {$_.length -gt 100KB} | Get-FileHash -Algorithm MD5
Write-Verbose "Hashed $($h.count) files"
$h | ConvertTo-Json | Out-File c:\work\hashinfo.json
You don’t need a separate book to “teach” you how to use Get-FileHash
and ConvertTo-Json
. You need to know how to find the commands you need to achieve a task, how to discover how to use them, and how to write a PowerShell pipelined expression to use them effectively. This process should be your PowerShell learning objective.
Finding a Learning Resource
As I mentioned, the PowerShell community has embraced the Month of Lunches books as an authoritative learning reference. But I am not so bold as to imagine the books Don and I wrote are the only ones. I suppose I should point out that I have always approached PowerShell from an IT pro’s perspective. How can an IT pro learn and use PowerShell to better do their job? Or, as Jeffrey Snover has famously referenced, “Put out the fires.”
As you look for other resources for learning PowerShell, especially the fundamentals, I suggest keeping these questions in mind. First, is the content focused on a specific PowerShell use case? Is the author’s focus on a pre-determined set of commands? A book that focuses on using PowerShell to manage AWS might be great if I need to manage AWS, but it probably isn’t going to give me the broad, foundational PowerShell skills I need as a beginner. Look for a resource that focuses on core concepts and techniques.
Naturally, you want to validate the author’s expertise and qualifications. Does the author have adequate real-world PowerShell experience? Why do they feel best qualified to teach you PowerShell? And don’t rely on credentials, job titles, or employers. Sadly, I have seen my share of poor PowerShell from people working at major software companies with serious-sounding job titles. Based on my long experience with PowerShell, I’d hesitate before using a resource from these types of authors. I guess this is where reviews and the opinion of the PowerShell community come into play.
I would also stay away from PowerShell books with a developer focus. At least for learning PowerShell fundamentals. Windows PowerShell in Action by Bruce Payette and Richard Siddaway is a terrific book full of deep content that can only come from someone (Bruce) who helped write the language. But I would hesitate to recommend this title as a beginning reference. Bruce and Richard’s book is an excellent reference once you have been using PowerShell for a while and want to dive deeper into the language.
Read, Do, Refine, Repeat
When looking for learning material, I also encourage you to find material that includes hands-on learning. If all you ever do is read about PowerShell, you’ll never really learn it. Learning PowerShell is no different than learning a foreign language. If I want to improve my Swedish language skills, the only way is by actually speaking and writing Swedish as much as possible. There is a reason immersive language learning works.
The approach Don and I take, and of others, is to introduce an idea, demonstrate it, provide you an opportunity to test your understanding, and then reinforce the topic, typically reviewing a possible solution to the testing phase.
To truly learn PowerShell, you have to use it every day. That’s one of the reasons I wrote The PowerShell Practice Primer. You need to figure out what PowerShell command you need to accomplish a task and how to use the command or commands. You’ll likely learn, try something, refine it, and try again until you get a working solution. Errors in your work at this stage are merely learning opportunities. Take the time to read error messages and then refine your command. This process of reading, trying, refining, repeat is the key to genuinely learning PowerShell.
Teaching Not Training
The last concept I want to leave you with regarding PowerShell is to emphasize teaching, not training. I feel this is a subtle yet critical distinction. I consider myself a teacher, not a trainer. I think how I write and create my Pluralsight courses reflects this principle. I fervently believe in the “teach a man to fish” paradigm. Training, at least to me, implies learning a pre-defined set of steps to achieve a specific goal. Years ago, I took a training class on installing Windows NT Server. And it was a proper training class. You had to follow a specific set of steps and answer prompts in a certain way to install NT. You probably received training in your job. Maybe on how to enter a trouble ticket or the steps for enabling a new user in Microsoft 365. You don’t have to understand how or why it works, only the steps to take.
PowerShell is not like that. Sure, I could “train” you on how to use the Hyper-V cmdlets to set up a new virtual machine. But you would be better served by understanding how to use the Hyper-V cmdlets in a PowerShell environment and what to do if something goes wrong. Even better, I want to teach you how to be flexible in PowerShell. I want to teach you the PowerShell paradigm and concepts so that you can use PowerShell to achieve a task like this:
Importing data from a CSV file, create multiple Hyper-V virtual machines enabling automatic checkpoints. When the machine is first created take a baseline snapshot and export the snapshot to a backup location. Finally, create a log file of all activities.
The solution will not be a single PowerShell expression, but it could be a series of PowerShell commands you would type interactively at a console. The important part is that you understand the PowerShell concepts on achieving this task. If your boss says, “We now need to do everything in Azure” at some point in the future, you don’t have to re-learn PowerShell. You only need to learn the comparable Azure cmdlets. The new Azure approach will be much more challenging if you’ve only been “trained” in the Hyper-V virtual machine creation process.
All that said, there is still a place for books like The PowerShell Cookbook by Lee Holmes. These resources demonstrate how to achieve tasks with PowerShell. Again, I wouldn’t recommend a book like this to learn PowerShell fundamentals. But it is a terrific resource for expanding your PowerShell knowledge and experience. You should look at the material and always be thinking, “How else could I use or extend this idea?”
Learning Never Ends
Learning PowerShell never ends, even though specific phases of learning PowerShell will pass. I’m assuming most of you no longer consider yourself a beginner. But there is always something new to learn. Despite the number of years I’ve been using PowerShell, I still learn new things all the time. Primarily because I’m using it every day and constantly pushing myself to do more with it. If you focus on the big picture and view PowerShell as a management tool with an endless number of settings, I think you’ll embrace PowerShell and enjoy the learning experience. In my experience, people with pre-determined and fixed opinions about what PowerShell is and how it should work struggle the most to learn PowerShell. I’ll be the first to admit that PowerShell isn’t the perfect tool for every situation. But if you learn PowerShell for what it is and do not get distracted by specific commands and language features, you’ll find it well worth the investment.