Chapter 2. Learning PowerShell

 

This chapter covers

  • Installing and configuring PowerShell
  • Self-discovery
  • Language features
  • Scripts

We’ll have created an automation toolkit by the time we reach the end of the book. The core of that toolkit is PowerShell itself. We’ve looked at the fundamentals of PowerShell; now we learn how to use it. Think of it as unpacking a shiny new tool, putting the bits together, and learning how to use it.

When I downloaded the first beta of PowerShell, I remember installing it, clicking the icon to start it, then having one of those “What on Earth is this?” moments. I usually mention this when giving talks about PowerShell, and often someone comes up to me and says she had the same problem. I spent a lot of time working through the documentation, searching the internet, and experimenting through trial and (lots of) error to find out how this stuff worked. This chapter will be your shortcut to that learning process; I’ll show you the self-discovery mechanisms in PowerShell as well as provide usable examples of how it works.

We start by discovering how to install and configure PowerShell. The main configuration item is the PowerShell profile, what you put in it, and where you store it. It’s possible to have four profiles—though not recommended—and I’ll explain which to use when. Once PowerShell is configured, we can start learning how to use it. This is done by using PowerShell’s self-discovery mechanisms. We’ll find four new friends along this journey.

2.1. Open the book—learn by doing

2.2. Installation and configuration

2.3. Your four best friends

2.4. Language features

2.5. Scripts

2.6. Summary