Chapter 5. Scripting language crash course
We don’t typically enjoy presenting material up front that you won’t put to use right away. In this case, though, we’re going to make an exception. You’ll be writing scripts in this book, and that means including a certain amount of code. PowerShell’s scripting language is super-simple, containing under two dozen actual keywords, and we’re only going to use about a dozen in this book. But we need to get the most important of those into your head so that we can use them at will when the time comes. Our goal in this chapter is not to provide complete coverage of these items but to give you a quick introduction. When you see them in use throughout the rest of the book, they’ll begin to make more sense.
Tip
To learn even more about the material in this chapter, the first place to look is PowerShell’s help system. Much of this is documented in about topics. You can try looking at things like about_if and about_comparison_operators. Or grab a copy of PowerShell in Depth (Manning, 2013, www.manning.com/books/powershell-in-depth).
Almost all of the scripting bits we’ll introduce in this chapter rely on comparisons. That is, you give them some statement that must evaluate to either True or False, and the scripting constructs base their behavior on that result. In order to make a comparison in PowerShell, you use a comparison operator. PowerShell’s core ones are as follows: