Learn PowerShell Scripting in a Month of Lunches
Don Jones and Jeffery Hicks
  • MEAP began July 2017
  • Publication in Fall 2017 (estimated)
  • ISBN 9781617295096
  • 325 pages (estimated)
  • printed in black & white


An eBook copy of the previous edition, Learn PowerShell Toolmaking in a Month of Lunches, is included at no additional cost. It will be automatically added to your Manning account within 24 hours of purchase.

Inside you'll discover how scripting is different from command-line PowerShell, as you explore concrete hands-on examples. You'll master good habits for elegant, efficient, and error-free scripting along with best practices and easy-to-digest tips that any professional PowerShell scripter needs to know. You'll also get to grips with the process of developing, testing, and deploying scripts and tackle the art of PowerShell toolmaking. This book includes and expands on many of the techniques presented in Learn PowerShell Toolmaking in a Month of Lunches.

Table of Contents detailed table of contents

Part 1: Introduction to Scripting

1. Before you begin

1.1. What is toolmaking?

1.2. Is this book for you?

1.3. Here’s what you need to have

1.3.1. PowerShell version

1.3.2. Administrative privileges

1.3.3. SQL Server

1.3.4. Script editor

1.4. How to use this book

1.5. How to ask for help

1.6. Summary

2. Setting up your scripting environment

2.1. The Operating System

2.2. Windows PowerShell

2.3. Administrative Privileges and Execution Policy

2.4. A Script Editor

2.5. Setup a Virtual Environment

2.6. Example Code

2.7. Your Turn

3. WWPD: What would PowerShell do?

3.1. Writing Single-Task Tools

3.2. Naming Tools

3.3. Naming Parameters

3.4. Producing Output

3.5. Don’t Assume

3.6. Avoid Innovation

3.7. Summary

4. Review: Parameter Binding and the PowerShell Pipeline

4.1. Visualizing the Pipeline

4.2. It’s all in the parameters

4.3. Plan A: ByValue

4.3.1. Introducing Trace-Command

4.3.2. Tracing ByValue Parameter Binding

4.3.3. When ByValue Fails

4.4. ByPropertyName

4.4.1. Let’s trace ByPropertyName

4.4.2. When ByPropertyName fails

4.4.3. Planning Ahead

4.5. Summary

5. Scripting Language Crash Course

5.1. The If Construct

5.2. The ForEach Construct

5.3. The Switch Construct

5.4. The Do/While Construct

5.5. The For Construct

5.6. Break

5.7. Summary

6. The many forms of scripting (and which to use)

6.1. Tools vs. controllers

6.2. Thinking about tools

6.3. Thinking about controllers

6.4. Comparing tools and controllers

6.5. Summary

7. Scripts and Security

7.1. PowerShell’s Script Security Goal

7.2. Execution Policy

7.2.1. Execution Scope

7.2.2. Getting Your Policies

7.2.3. Setting an Execution Policy

7.3. PowerShell isn’t the Default Application

7.4. Running Scripts

7.5. Recommendations

7.6. Summary

Part 2: Building a PowerShell Script

8. Always Design First

8.1. Tools Do One Thing

8.2. Tools are Testable

8.3. Tools are Flexible

8.4. Tools Look Native

8.5. For Example

8.6. Your Turn

8.6.1. Start Here

8.6.2. Your Task

8.6.3. Our Take

9. Avoid Bugs: Start with a Command

9.1. What We Need to Run

9.2. Breaking it Down and Running it Right

9.3. Running Commands and Digging Deeper

9.4. Process Matters

9.5. Your Turn

9.5.1. Start Here

9.5.2. Your Task

9.5.3. Our Take

10. Build a Basic Function and Script Module

10.1. Start with a Basic Function

10.1.1. Design the Input Parameters

10.1.2. Write the Code

10.1.3. Design the Output

10.2. Create a Script Module

10.3. Pre-Req Check

10.4. Running the Command

10.5. Your Turn

10.5.1. Start Here

10.5.2. Your Task

10.5.3. Our Take

11. Going Advanced With Your Function

11.1. About CmdletBinding and Common Parameters

11.1.1. Accepting Pipeline Input

11.1.2. Mandatory-ness

11.1.3. Parameter Validation

11.1.4. Parameter Aliases

11.1.5. Your Turn

12. Objects: The Best Kind of Output

12.1. Assembling the Information

12.2. Constructing and Emitting Output

12.3. A Quick Test

12.4. An Object Alternative

12.5. Your Turn

12.5.1. Start Here

12.5.2. Your Task

12.5.3. Our Take

13. Using All the Pipelines

14. Simple Help: Make a Comment

15. Dealing with Errors

16. Filling out a Manifest

Part 3: Grown-Up Scripting

17. Change Your Brain When it Comes to Scripting

18. Professional-Grade Scripting Practices

19. An Introduction to Git Source Control

20. Pestering Your Script

21. Signing Your Script

22. Publishing Your Script

Part 4: Advanced Techniques

23. Squashing Bugs

24. Making Script Output Prettier

25. Wrapping up the .NET Framework

26. Storing Data (not in Excel!)

27. Never the End

About the Technology

PowerShell is both a scripting language and an administrative shell that lets you control and manage nearly every aspect of Windows, from Azure to SharePoint. Because it's a full-featured programming language, PowerShell is a powerful toolkit for building custom scripts to automate Windows administration tasks large and small. It's also a great platform for building reusable tools and utilities that make everyday administration faster and easier.

What's inside

  • A crash course in PowerShell Scripting
  • Designing and building functions and script modules
  • Effective pipeline usage
  • Dealing with errors and squashing bugs
  • Professional-grade scripting practices

About the reader

Written for developers and administrators comfortable with PowerShell as a command-line interface and familiar with Windows administration in general.

About the author

Don Jones is a PowerShell MVP, speaker, and trainer who has written dozens of books on information technology topics. Jeffery Hicks is a PowerShell MVP and an independent consultant, trainer, and author. Don and Jeff co-authored Learn Windows PowerShell in a Month of Lunches and PowerShell in Depth.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $44.99 pBook + eBook + liveBook
MEAP eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks