Learn PowerShell Toolmaking in a Month of Lunches
Don Jones and Jeffery D. Hicks
  • December 2012
  • ISBN 9781617291166
  • 312 pages
  • printed in black & white

Yet another great book from PowerShell legends, Don and Jeff.

Thomas Lee, PowerShell MVP


Learn PowerShell Scripting in a Month of Lunches is now available in the Manning Early Access Program. An eBook of this older edition is included at no additional cost when you buy the revised edition!

You may still purchase Learn PowerShell Toolmaking in a Month of Lunches using the Buy options on this page.

Packed with hands-on labs to reinforce what you're learning, Learn PowerShell Toolmaking in a Month of Lunches is the best way to learn PowerShell scripting and toolmaking. Just set aside one hour a day—lunchtime would be perfect—for each self-contained lesson. You'll move quickly through core scripting concepts and start working on four real-world, practical tools. Each chapter adds more functionality, including custom formatting, error handling, parameterized input, input validation, help files and documentation, and more.

Table of Contents detailed table of contents


about this book

about the authors


Part 1 Introduction to toolmaking

1. Before you begin

1.1. What is toolmaking?

1.2. Is this book for you?

1.3. Prerequisites

1.4. How to use this book

2. PowerShell scripting overview

2.1. What is PowerShell scripting?

2.2. PowerShell’s execution policy

2.3. Running scripts

2.4. Editing scripts

2.5. Further exploration: script editors

2.6. Lab

3. PowerShell’s scripting language

3.1. One script, one pipeline

3.2. Variables

3.3. Quotation marks

3.4. Object members and variables

3.5. Parentheses

3.6. Refresher: comparisons

3.7. Logical constructs

3.8. Looping constructs

3.9. Break and Continue in constructs

3.10. Lab

4. Simple scripts and functions

4.1. Start with a command

4.2. Turn the command into a script

4.3. Parameterize the command

4.4. Turn the script into a function

4.5. Testing the function

4.6. Lab

5. Scope

5.1. What is scope?

5.2. Seeing scope in action

5.3. Working out of scope

5.4. Getting strict with scope

5.5. Best practices for scope

5.6. Lab

Part 2 Building an inventory tool

6. Tool design guidelines

6.1. Do one thing, and do it well

6.2. Labs

7. Advanced functions, part 1

7.1. Advanced function template

7.2. Designing the function

7.3. Declaring parameters

7.4. Testing the parameters

7.5. Writing the main code

7.6. Outputting custom objects

7.7. What not to do

7.8. Coming up next

7.9. Labs

8. Advanced functions, part 2

8.1. Making parameters mandatory

8.2. Verbose output

8.3. Parameter aliases

8.4. Accepting pipeline input

8.5. Parameter validation

8.6. Adding a switch parameter

8.7. Parameter help

8.8. Coming up next

8.9. Labs

9. Writing help

9.1. Comment-based help

9.2. XML-based help

9.3. Coming up next

9.4. Labs

10. Error handling

10.1. It’s all about the action

10.2. Setting the error action

10.3. Saving the error

10.4. Error handling v1: Trap

10.5. Error Handling v2+: Try…Catch…Finally

10.6. Providing some visuals

10.7. Coming up next

10.8. Labs

11. Debugging techniques

11.1. Two types of bugs

11.2. Solving typos

11.3. The real trick to debugging: expectations

11.4. Dealing with logic errors: trace code

11.5. Dealing with logic errors: breakpoints

11.6. Seriously, have expectations

11.7. Coming up next

11.8. Lab

12. Creating custom format views

12.1. The anatomy of a view

12.2. Adding a type name to output objects

12.3. Making a view

12.4. Loading and debugging the view

12.5. Using the view

12.6. Coming up next

12.7. Labs

13. Script and manifest modules

13.1. Introducing modules

13.2. Creating a script module

13.3. Creating a module manifest

13.4. Creating a module-level setting variable

13.5. Coming up next

13.6. Lab

14. Adding database access

14.1. Simplifying database access

14.2. Setting up your environment

14.3. The database functions

14.4. About the database functions

14.5. Using the database functions

14.6. Lab

15. Interlude: creating a new tool

15.1. Designing the tool

15.2. Writing and testing the function

15.3. Dressing up the parameters

15.4. Adding help

15.5. Handling errors

15.6. Making a module

15.7. Coming up next

Part 3 Advanced toolmaking techniques

16. Making tools that make changes

16.1. The –Confirm and –WhatIf parameters

16.2. Passthrough ShouldProcess

16.3. Defining the impact level

16.4. Implementing ShouldProcess

16.5. Lab

17. Creating a custom type extension

17.1. The anatomy of an extension

17.2. Creating a script property

17.3. Creating a script method

17.4. Loading the extension

17.5. Testing the extension

17.6. Adding the extension to a manifest

17.7. Lab

18. Creating PowerShell workflows

18.1. Workflow overview

18.2. General workflow design strategy

18.3. Example workflow scenario

18.4. Writing the workflow

18.5. Workflows vs. functions

18.6. Lab

19. Troubleshooting pipeline input

19.1. Refresher: how pipeline input works

19.2. Introducing Trace-Command

19.3. Interpreting trace-command output

19.4. Lab

20. Using object hierarchies for complex output

20.1. When a hierarchy might be necessary

20.2. Hierarchies and CSV: not a good idea

20.3. Creating nested objects

20.4. Working with nested objects

20.5. Lab

21. Globalizing a function

21.1. Introduction to globalization

21.2. PowerShell’s data language

21.3. Storing translated strings

21.4. Do you need to globalize?

21.5. Lab

22. Crossing the line: utilizing the .NET Framework

22.1. .NET classes and instances

22.2. Static methods of a class

22.3. Instantiating a class

22.4. Using Reflection

22.5. Finding class documentation

22.6. PowerShell vs. Visual Studio

22.7. Lab

Part 4 Creating tools for delegated administration

23. Creating a GUI tool, part 1: the GUI

23.1. Introduction to WinForms

23.2. Using a GUI to create the GUI

23.3. Manually coding the GUI

23.4. Showing the GUI

23.5. Lab

24. Creating a GUI tool, part 2: the code

24.1. Addressing GUI objects

24.2. Example: text boxes

24.3. Example: button clicks

24.4. Example: list boxes

24.5. Example: radio buttons

=== === Example: check boxes === Lab

25. Creating a GUI tool, part 3: the output

25.1. Using Out-GridView

25.2. Creating a form for output

25.3. Populating and showing the output

25.4. Lab

26. Creating proxy functions

26.1. What are proxy functions?

26.2. Creating the proxy function template

26.3. Removing a parameter

26.4. Adding a parameter

26.5. Loading the proxy function

26.6. Lab

27. Setting up constrained remoting endpoints

27.1. Refresher: Remoting architecture

27.2. What are constrained endpoints?

27.3. Creating the endpoint definition

27.4. Registering the endpoint

27.5. Connecting to the endpoint

27.6. Lab

28. Never the end

28.1. Welcome to toolmaking

28.2. Cool ideas for tools

28.3. What’s your next step?

Appendix A: appendix GUI technologies and PowerShell


© 2014 Manning Publications Co.

About the book

You don't have to be a software developer to build PowerShell tools. With this book, a PowerShell user is a step away from becoming a proficient toolmaker.

Learn PowerShell Toolmaking in a Month of Lunches is the best way to learn PowerShell scripting and toolmaking in just one hour a day. It's packed with hands-on labs to reinforce what you're learning. It's an easy-to-follow guide that covers core scripting concepts using four practical examples. Each chapter builds on the previous one as you add custom formatting, error handling, input validation, help files, and more.

What's inside

  • Build your own administrative tools
  • Learn by doing with hands-on labs
  • Make scripts that feel like native PowerShell cmdlets

About the reader

This book does not assume you are a programmer. Experience using PowerShell as a command-line interface is helpful but not required.

About the author

Don Jones is a PowerShell MVP, speaker, and trainer. Jeffery Hicks is a PowerShell MVP and an independent consultant, trainer, and author. Don and Jeff coauthored Learn Windows PowerShell 3 in a Month of Lunches, Second Edition (Manning 2012) and PowerShell in Depth (Manning 2013).

combo $44.99 pBook + eBook + liveBook
eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks

An excellent resource to begin learning a must-have skill set.

Marc Johnson, Triangle Technology

Take your PowerShell skills to the next level.

Nathan Shelby, Snohomish Health District

A perfect guide for creating PowerShell tools.

Christoph Tohermes, netzkern AG