We recently received a copy of Windows PowerShell 3.0 First Steps and I decided to take on the challenge of reviewing it, mainly for two reasons. The first one is that I have never reviewed a book before and I saw it as a great exercise in this direction. The second reason is the fact that this book is written with PowerShell beginners in mind and - you guessed it - I'm a PowerShell beginner. Actually, that would be an overstatement, since I have never used PowerShell before, so I considered it a great way to get to learn a new skill. Without further ado, let's dive in and see if this book is worth buying.
Who's Going To Teach Me PowerShell?
The author of Windows PowerShell 3.0 First Steps is Ed Wilson. As the cover of his book informs us, Ed is a senior consultant at Microsoft and a well-known scripting expert. Given his skills, he seems to be one of Microsoft's go-to guys when it comes to presenting scripting workshops to Microsoft customers and employees around the globe.
Ed is also the author of Windows PowerShell 2.0 Best Practices, Microsoft VBScript Step by Step, and has his own TechNet blog on which he talks about scripting. I didn't really dig into his work until now, but given these facts I'd say the guy knows what he's talking about so, at the first glance, I would happily take his advice on learning PowerShell.
Putting Things Into Perspective
Ed Wilson wrote this book for complete beginners and advises you to read it from cover to cover. The tone in which this book is written is a friendly one, very easy to understand. The author doesn't use a highly technical jargon while teaching you PowerShell, so unless you have just bought a computer and are just learning to use it, you should not have any problem understanding the lessons and the examples that Ed included.
To get a better overview of how this almost 300 pages book is structured, here's a list of the chapters and what to expect in each one:
- Chapter 1 - Overview of Windows PowerShell 3.0 - This first chapter gives you a very good and comprehensible overview of what PowerShell is and also shows some of the differences between the Windows PowerShell console and the Windows PowerShell Integrated Scripting Environment, which you will be using later on in the book. You also learn about the verbs and naming conventions used in Powershell as well as a few basic security aspects that directly impact the usage of PowerShell.
- Chapter 2 - Using Windows PowerShell cmdlets - Consider this chapter the ABC of PowerShell. Cmdlets are the heart of PowerShell and if you really want to learn to use it, you'll need to master cmdlets first. Fortunately, Ed does a great job at explaining both their role and their structure, and quickly gives you lots of examples that you can run on your own computer and test them yourself to see the effect. Some of the examples given here include searching the Help topics of PowerShell or using the Get-Command cmdlet to find other cmdlets. The chapter ends with sections on setting up a Script Execution Policy (don't worry, you'll learn what that is as well) and creating a basic Windows PowerShell profile.
- Chapter 3 - Filtering, grouping, and sorting - PowerShell is great at giving you thorough insight into different types of data. This chapter starts by taking you through an introduction to the pipeline and goes on by teaching you how to sort, group or filter the information you get from using different cmdlets.
- Chapter 4 - Formatting output - Displaying raw data in the PowerShell console might not always be the best way to view it. The fourth chapter of the book gives you a hands-on demonstration of how to create a table in PowerShell and use it to display the data you need in an organized fashion. It also shows you how to use the output grid, a feature that I bet many of you will love.
- Chapter 5 - Storing output - Once you get the hang of pulling information from PowerShell, Ed shows how to store that information in different tools. He demonstrates this by storing information in csv, txt and xml files.
Chapter 6 - Leveraging Windows PowerShell providers - This is where the book starts to get more technical. But hey, that's what you here for, right? After all, we are talking about one of the most powerful tools you will find in Microsoft's operating systems! This chapter explains what Windows PowerShell providers are and carefully examines the Alias provider, Certificate provider, Environment provider, File System provider, Function provider, Registry provider, and Variable
provider. Now calm down and take a deep breath. By the time you get here while carefully reading and practicing the examples shown in the book, you'll have a decent enough understanding of PowerShell to not get lost in technical terms.
- Chapter 7 - Using Windows PowerShell remoting - In my opinion this is one of the most important chapters of the book. Take your time while reading it and give it a second or third read if you feel that you need to, because this is where the real strength of PowerShell is shown. I would go as far as to say that the contents of this section is what puts the word power in PowerShell. Here you'll learn how to run commands on a remote computer, create persistent connections and also do some troubleshooting.
- Chapter 8 - Using WMI - This chapter goes into detail regarding Windows Management Instrumentation, which Microsoft has included in every operating system since Windows NT 4.0. Yes, it's that important. You will learn about WMI classes, providers and namespaces and will test your knowledge through querying WMI in two different ways. If you're familiar with SQL you'll feel right at home with at least one of the two methods.
- Chapter 9 - Using CIM - Common Information Model (CIM) provides an interesting way to retrieve information from Windows Management Instrumentation. Ed Wilson does a good job explaining how and why to use this feature, both locally and remotely.
- Chapter 10 - Using the Windows PowerShell ISE - The Windows PowerShell ISE is a more interactive way of using PowerShell for pretty much everything that the books has discussed so far. You will learn how to use the environment, the tab expansion feature and the Output pane. The book also covers how to create and remove ISE snippets (yes, you will learn what these are as well).
- Chapter 11 - Using Windows PowerShell scripts - PowerShell offers a great deal of options for network management and administration. If you're an IT administrator, you will most likely encounter recurring needs in your daily tasks, that can be simplifies by writing your own scripts and running them from PowerShell. While some familiarity with VBScript or any other scripting or programming language would be of use in understanding this chapter, I wouldn't call it mandatory. Ed wrote this book for beginners and it's not hard to understand the scripts exemplified in this chapter even if you haven't written a line of code yet. The chapter presents some reasons to write scripts, shows you how to run them, how to set the script execution policy and teaches you about variables and different language statements.
- Chapter 12 - Working with functions - Functions are the primary programming element when it comes to writing PowerShell scripts. The chapter begins with an introduction to functions and their usage and goes on explaining how to use parameters for input. It also includes two special scenarios for using functions.
- Chapter 13 - Debugging scripts - There's a saying that goes something like "The best debugging is no debugging.". Of course, that rarely happens in real life. This chapter will take you through script debugging and its importance, setting, listing, enabling and disabling breakpoints in PowerShell scripts.
- Chapter 14 - Handling errors - Ed Wilson gracefully concludes the PowerShell lessons with a chapter dedicated to error handling. The chapter begins with a good approach on missing parameters and goes on teaching you about limiting choices and reviewing how to handle missing rights. You also learn structured error handling.
The book includes two appendix sections, one containing a PowerShell FAQ and the other one explaining PowerShell 3.0 coding conventions in a friendly and understandable manner, so that you also learn some best practices in terms of script readability and maintenance.
That's How That Works... But Here's Why
A great thing about Ed's teaching style is his approach to explaining the reason why you need to do things a certain way and not using a monkey see, monkey do approach. Each chapter starts with simple explanations and an overview of the matter at hand. Then it advances to more specific tasks while also giving you an insight of why you need to do this and that. Being a beginner oriented book, I can only praise this approach and hope to see it in as many books as possible, especially technical ones.
Each chapter ends with a summary of the information it contains, serving as a wrap-up and a memory refresher for you to better understand and keep the information in mind.
Did It Help Me?
The short answer: Yes!
The author takes a fairly complex subject and one of the most complex tools that have ever been included in Windows and explains it in a way that's both easy to understand and interesting enough to keep you hooked. I have never used PowerShell before but, after reading the book, I can safely say that I have a basic understanding of what PowerShell is, how it works and who would best benefit from its usage. I didn't get into too much scripting, but this will definitely be a topic we will soon cover here, at 7 Tutorials, and Ed Wilson's book will be our Bible while doing that.
While those of you familiar with Ed Wilson's style will most definitely enjoy Windows PowerShell 3.0 First Steps, I could say the same for complete beginners. The concepts and examples are very well explained and you get some practical, do-it-yourself experience in each chapter, which can only be great for learning. While the book offers newcomers a great starting point in using PowerShell, more useful scripters or IT administrators might find it useful as well, especially the scripting chapters and the coding conventions appendix. Given that this is a book that basically shows you that you don't need to be a computer expert to be able to learn how to write scripts and automate or manage network tasks, I would highly recommend it for a newcomer to PowerShell.