Learn Windows PowerShell in a Month of Lunches
Don Jones
  • April 2011
  • ISBN 9781617290213
  • 336 pages
  • printed in black & white
This title is out of print and no longer for sale.

A seminal guide to PowerShell. Highly recommended.

Ray Booysen, BNP Paribas

Second edition of this book is available

Learn Windows PowerShell in a Month of Lunches is an innovative tutorial designed for busy administrators. Author Don Jones brings many years of successful training techniques to this concise, easy-to-follow book. Just set aside one hour a day—lunchtime would be perfect—for a month, and you'll be automating administrative tasks faster than you ever thought possible.

Table of Contents show full


about this book

about the author


1. Before you begin

1.1. Why you can’t afford to ignore PowerShell

1.2. Is this book for you?

1.3. How to use this book

1.4. Setting up your lab environment

1.5. Installing Windows PowerShell

1.6. Online resources

1.7. Being immediately effective with PowerShell

2. Running commands

2.1. Not scripting: just running commands

2.2. Opening PowerShell

2.3. Managing files and folders—you know this!

2.4. Accuracy counts

2.5. Not just files and folders: introducing PSDrives

2.6. Support for external commands

2.7. The same old commands—almost

2.8. Common points of confusion

2.9. Lab

3. Using the help system

3.1. The help system: how you discover commands

3.2. Asking for help

3.3. Using help to find commands

3.4. Interpreting the help

3.5. Accessing "about" topics

3.6. Accessing online help

3.7. Lab

3.8. Ideas for on your own

4. The pipeline: connecting commands

4.1. Connect one command to another: less work for you!

4.2. Exporting to a CSV or XML file

4.3. Piping to a file or printer

4.4. Converting to HTML

4.5. Using cmdlets to kill processes and stop services

4.6. Lab

5. Adding commands

5.1. How one shell can do everything

5.2. About product-specific management shells

5.3. Extensions: finding and adding snap-ins

5.4. Extensions: finding and adding modules

5.5. Command conflict and removing extensions

5.6. Finding help on newly added commands

5.7. Playing with Server Manager via command line!

5.8. Profile scripts: preloading extensions when the shell starts

5.9. Common points of confusion

5.10. Lab

5.11. Ideas for on your own

6. Objects: just data by another name

6.1. What are objects?

6.2. Why PowerShell uses objects

6.3. Discovering objects: Get-Member

6.4. Object attributes, or "properties"

6.5. Object actions, or "methods"

6.6. Sorting objects

6.7. Selecting the properties you want

6.8. Objects until the very end

6.9. Common points of confusion

6.10. Lab

7. The pipeline, deeper

7.1. The pipeline: enabling power with less typing

7.2. Pipeline input ByValue, or why Stop-Service works

7.3. Parentheses instead of pipelines

7.4. Pipeline input ByPropertyName

7.5. Creating new AD users, fast and easy

7.6. When things don’t line up: custom properties

7.7. Extracting the value from a single property

7.8. Lab

8. Formatting—and why it’s done on the right

8.1. Formatting: making what you see prettier

8.2. About the default formatting

8.3. Formatting tables

8.4. Formatting lists

8.5. Formatting wide

8.6. Custom columns and list entries

8.7. Going out: to a file, a printer, or the host

8.8. Another out: GridViews

8.9. Common points of confusion

8.10. Lab

8.11. Ideas for on your own

9. Filtering and comparisons

9.1. Making the shell give you just what you need

9.2. Filter left

9.3. Comparison operators

9.4. Filtering objects out of the pipeline

9.5. The iterative command-line model

9.6. Common points of confusion

9.7. Lab

9.8. Ideas for on your own

10. Remote control: one to one, and one to many

10.1. The idea behind remote PowerShell

10.2. WinRM overview

10.3. Using Enter-PSSession and Exit-PSSession for 1:1 remoting

10.4. Using Invoke-Command for one-to-many remoting

10.5. Differences between remote and local commands

10.6. But wait, there’s more

10.7. Common points of confusion

10.8. Lab

10.9. Ideas for on your own

11. Tackling Windows Management Instrumentation

11.1. Retrieving management information

11.2. A WMI primer

11.3. The bad news about WMI

11.4. Exploring WMI

11.5. Using Get-WmiObject

11.6. WMI documentation

11.7. Common points of confusion

11.8. Lab

11.9. Ideas for on your own

12. Multitasking with background jobs

12.1. Making PowerShell do multiple things at the same time

12.2. Synchronous versus asynchronous

12.3. Creating a local job

12.4. WMI, as a job

12.5. Remoting, as a job

12.6. Getting job results

12.7. Working with child jobs

12.8. Commands for managing jobs

12.9. Common points of confusion

13. Working with bunches of objects, one at a time

13.1. Automation for mass management

13.2. The preferred way: batch cmdlets

13.3. The WMI way: invoking WMI methods

13.4. The backup plan: enumerating objects

13.5. Common points of confusion

13.6. Lab

14. Security alert!

14.1. Keeping the shell secure

14.2. Windows PowerShell security goals

14.3. Execution policy and code signing

14.4. Other security measures

14.5. Other security holes?

14.6. Security recommendations

14.7. Lab

15. Variables: a place to store your stuff

15.1. Introduction to variables

15.2. Storing values in variables

15.3. Fun tricks with quotes

15.4. Storing lots of objects in a variable

15.5. Declaring a variable’s type

15.6. Commands for working with variables

15.7. Variable best practices

15.8. Common points of confusion

15.9. Lab

15.10. Ideas for on your own

16. Input and output

16.1. Prompting for, and displaying, information

16.2. Read-Host

16.3. Write-Host

16.4. Write-Output

16.5. Other ways to write

16.6. Lab

16.7. Ideas for on your own

17. You call this scripting?

17.1. Not programming…​ more like batch files

17.2. Making commands repeatable

17.3. Parameterizing commands

17.4. Creating a parameterized script

17.5. ocumenting your script

17.6. One script, one pipeline

17.7. A quick look at scope

17.8. Lab

17.9. Ideas for on your own

18. Sessions: remote control, with less work

18.1. Making PowerShell remoting a bit easier

18.2. Creating and using reusable sessions

18.3. Using sessions with Enter-PSSession

18.4. Using sessions with Invoke-Command

18.5. Implicit remoting: importing a session

18.6. Lab

18.7. Ideas for on your own

19. From command to script to function

19.1. Turning a command into a reusable tool

19.2. Modularizing: one task, one function

19.3. Simple and parameterized functions

19.4. Returning a value from a function

19.5. Returning objects from a function

19.6. Lab

19.7. Ideas for on your own

20. Adding logic and loops

20.1. Automating complex, multi-step processes

20.2. Now we’re "scripting"

20.3. The If construct

20.4. The Switch construct

20.5. The For construct

20.6. The ForEach construct

20.7. Why scripting isn’t always necessary

20.8. Lab

21. Creating your own "cmdlets" and modules

21.1. Turning a reusable tool into a full-fledged cmdlet

21.2. Functions that work in the pipeline

21.3. Functions that look like cmdlets

21.4. Bundling functions into modules

21.5. Keeping support functions private

21.6. Lab

21.7. Ideas for on your own

22. Trapping and handling errors

22.1. Dealing with errors you just knew were going to happen

22.2. Errors and exceptions

22.3. The $ErrorActionPreference variable

22.4. The -ErrorAction parameter

22.5. Using a Trap construct

22.6. Trap scope

22.7. Using a Try construct

22.8. The -ErrorVariable parameter

22.9. Common points of confusion

22.10. Lab

22.11. Ideas for on your own

23. Debugging techniques

23.1. An easy guide to eliminating bugs

23.2. Identifying your expectations

23.3. Adding trace code

23.4. Working with breakpoints

23.5. Common points of confusion

23.6. Lab

24. Additional random tips, tricks, and techniques

24.1. Profiles, prompts, and colors: customizing the shell

24.2. Operators: -as, -is, -replace, -join, -split

24.3. String manipulation

24.4. Date manipulation

24.5. Dealing with WMI dates

25. Final exam: tackling an administrative task from scratch

25.1. Tips before you begin

25.2. Lab

25.3. Lab solution

26. Beyond the operating system: taking PowerShell further

26.1. Everything you’ve learned works the same everywhere

26.2. SharePoint Server 2010

26.3. VMware vSphere and vCenter

26.4. Third-party Active Directory management

27. Never the end

27.1. Ideas for further exploration

27.2. "Now that I’m done, where do I start?"

27.3. Other resources you’ll grow to love

28. PowerShell cheat sheet

28.1. Punctuation

28.2. Help file

28.3. Operators

28.4. Custom property and column syntax

28.5. Pipeline parameter input

28.6. When to use $_


About the Technology

Windows has so many control panels, consoles, APIs, and wizards it's really hard to keep track of all the locations and settings you'll need. PowerShell is a godsend: it provides a single, unified administrative command line. It accepts and executes commands immediately. And it has in-built language features that will let you write scripts to control any Windows component, including servers like Exchange, IIS, and Sharepoint.

About the book

Learn Windows PowerShell in a Month of Lunches is a newly designed tutorial for system administrators. Just set aside one hour a day—lunchtime would be perfect—for a month, and you'll be automating administrative tasks in a hurry. Author Don Jones combines his in-the-trenches experience with a unique teaching style to help you master the effective parts of PowerShell quickly and painlessly.

What's inside

  • Learn PowerShell 2 from the beginning-no experience required!
  • Written especially for administrators, not developers
  • Practical examples and reusable techniques in every concise 1-hour lesson

About the reader

The book is written for administrators, not developers.

About the author

Don Jones is a PowerShell MVP, speaker, and trainer. He developed the Microsoft PowerShell courseware and has taught PowerShell to more than 20,000 IT pros. Don writes the PowerShell column for TechNet Magazine and blogs for WindowsITPro.com.