Chapter 1. Welcome to PowerShell

 

This chapter covers:

  • 1.1 What is PowerShell?
  • 1.2 Soul of a new language
  • 1.3 Brushing up on objects
  • 1.4 Up and running with PowerShell
  • 1.5 Dude! Where’s my code?
  • 1.6 Summary

Space is big. Really big! You just won’t believe how vastly hugely mind-bogglingly big it is. I mean you may think it’s a long way down the road to the chemist, but that’s just peanuts compared to space!

Don’t Panic.

Douglas Adams, The Hitchhiker’s Guide to the Galaxy

Welcome to Windows PowerShell, the new command and scripting language from Microsoft. We begin this chapter with two quotes from The Hitchhiker’s Guide to the Galaxy. What do they have to do with a new scripting language? In essence, where a program solves a particular problem or problems, a programming language can solve any problem, at least in theory. That’s the “big, really big” part. The “Don’t Panic” bit is, well—don’t panic. Although PowerShell is new and different, it’s been designed to leverage what you already know, making it easy to learn. It’s also designed to allow you to learn it a bit at a time. Starting at the beginning, here’s the traditional “Hello world” program in PowerShell:

"Hello world."

As you can see, no panic needed. But “Hello world” by itself isn’t very interesting. Here’s something a bit more complicated:

dir $env:windir\*.log | Select-String -List error |
Format-Table path,linenumber –AutoSize

1.1. What is PowerShell?

1.2. Soul of a New Language

1.3. Brushing Up on Objects

1.4. Up and Running with PowerShell

1.5. Dude! Where’s My Code?

1.6. Summary