5 Scripting language: A crash course

 

In this book, you’ll notice that you’re only given general information immediately after using it. In this case, though, I’m going to make an exception. You’ll be writing scripts throughout this book, and that means including a certain amount of code. PowerShell’s scripting language is super simple, containing a few dozen actual keywords, and I’m only going to use about a dozen in this book. But we need to get the most important of those into our heads to use them when the time comes. The goal of this chapter isn’t to provide complete coverage of these items but to give you a quick introduction. They’ll begin to make more sense when you see them in use throughout the rest of the book.

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. For example, you can look at information regarding about_if and about_comparison_operators. You also can grab a copy of PowerShell in Depth, 2nd ed. (Manning, 2014; http://mng.bz/xjzq).

5.1 Comparisons

5.1.1 Wildcards

5.1.2 Collections

5.1.3 Troubleshooting comparisons

5.2 The If construct

5.3 The ForEach construct

5.4 The Switch construct

5.5 The Do/While construct

5.6 The For construct

5.7 Break

Summary