Windows PowerShell in Action, Second Edition
Bruce Payette
  • May 2011
  • ISBN 9781935182139
  • 1016 pages
  • printed in black & white

First he wrote the language, then he wrote the book.

Jeffrey Snover, MIcrosoft

Windows Powershell in Action, Second Edition is a completely revised edition of the bestselling book on PowerShell, written by Bruce Payette, one of the founding members of the Windows PowerShell team, codesigner of the PowerShell language, and the principal author of the PowerShell language implementation. The definitive book on PowerShell V2.

Table of Contents show full



about this book

about the cover illustration


Appendix A Comparing PowerShell to other languages

Appendix B Examples

Appendix C PowerShell Quick Reference

Appendix D Additional PowerShell topics

PART 1 Learning PowerShell

1. Welcome to PowerShell

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

2. Foundations of PowerShell

2.1. Getting a sense of the PowerShell language

2.2. The core concepts

2.3. Aliases and elastic syntax

2.4. Parsing and PowerShell

2.5. How the pipeline works

2.6. Formatting and output

2.7. Summary

3. Working with types

3.1. Type management in the wild, wild West

3.2. Basic types and literals

3.3. Collections: dictionaries and hash tables

3.4. Collections: arrays and sequences

3.5. Type literals

3.6. Type conversions

3.7. Summary

4. Operators and expressions

4.1. Arithmetic operators

4.2. The assignment operators

4.3. Comparison operators

4.4. Pattern matching and text manipulation

4.5. Logical and bitwise operators

4.6. Summary

5. Advanced operators and variables

5.1. Operators for working with types

5.2. The unary operators

5.3. Grouping and subexpressions

5.4. Array operators

5.5. Property and method operators

5.6. The format operator

5.7. Redirection and the redirection operators

5.8. Working with variables

5.9. Summary

6. Flow control in scripts

6.1. The conditional statement

6.2. Looping statements

6.3. Labels, break, and continue

6.4. The switch statement

6.5. Flow control using cmdlets

6.6. Statements as values

6.7. A word about performance

6.8. ummary

7. PowerShell functions

7.1. Fundamentals of PowerShell functions

7.2. Declaring formal parameters for a function

7.3. Returning values from functions

7.4. Using simple functions in a pipeline

7.5. Managing function definitions in a session

7.6. Variable scoping in functions

7.7. Summary

8. Advanced functions and scripts

8.1. PowerShell scripts

8.2. Writing advanced functions and scripts

8.3. Dynamic parameters and dynamicParam

8.4. Documenting functions and scripts

8.5. Summary

9. Using and authoring modules

9.1. The role of a module system

9.2. Module basics

9.3. Working with modules

9.4. Writing script modules

9.5. Binary modules

9.6. Summary

10. Module manifests and metadata

10.1. Module folder structure

10.2. Module manifest structure

10.3. Production manifest elements

10.4. Construction manifest elements

10.5. Content manifest elements

10.6. Language restrictions in a manifest

10.7. Advanced module operations

10.8. Summary

11. Metaprogramming with scriptblocks and dynamic code

11.1. Scriptblock basics

11.2. Building and manipulating objects

11.3. Using the Select-Object cmdlet

11.4. Dynamic modules

11.5. Steppable pipelines

11.6. A closer look at the type-system plumbing

11.7. Extending the PowerShell language

11.8. Building script code at runtime

11.9. Compiling code with Add-Type

11.10. Summary

12. Remoting and background jobs

12.1. Getting started with remoting

12.2. Applying PowerShell remoting

12.3. Sessions and persistent connections

12.4. Implicit remoting

12.5. Background jobs in PowerShell

12.6. Considerations when running commands remotely

12.7. Summary

13. Remoting: configuring applications and services

13.1. Remoting infrastructure in depth

13.2. Building custom remoting services

13.3. Summary

14. Errors and exceptions

14.1. Error handling

14.2. Dealing with errors that terminate execution

14.3. Debugging with the host APIs

14.4. Capturing session output

14.5. PowerShell and the event log

14.6. Summary

15. The PowerShell ISE and debugger

15.1. The PowerShell ISE

15.2. Using multiple PowerShell tabs

15.3. Extending the ISE

15.4. PowerShell script debugging features

15.5. The PowerShell v2 debugger

15.6. Command-line debugging

15.7. Summary

PART 2 Using PowerShell

16. Working with files, text, and XML

16.1. PowerShell and paths

16.2. File processing

16.3. Processing unstructured text

16.4. XML structured text processing

16.5. Summary

17. Extending your reach with .NET

17.1. Using .NET from PowerShell

17.2. PowerShell and the internet

17.3. PowerShell and graphical user interfaces

17.4. Summary

18. Working with COM

18.1. Working with COM in PowerShell

18.2. Automating Windows with COM

18.3. Working with the WScript.Shell class

18.4. Using COM to manage applications

18.5. The WSH ScriptControl class

18.6. Working with the Windows Task Scheduler

18.7. Issues with COM

18.8. Summary

19. Management objects: WMI and WS-MAN

19.1. Working with WMI in PowerShell

19.2. The WMI cmdlets

19.3. The WMI object adapter

19.4. Exploring WS-Man

19.5. Summary

20. Responding in real time with eventing

20.1. Foundations of event handling

20.2. Synchronous events

20.3. Asynchronous events

20.4. Working with asynchronous .NET events

20.5. Asynchronous event handling with scriptblocks

20.6. Queued events and the Wait-Event cmdlet

20.7. Working with WMI events

20.8. Engine events

20.9. Remoting and event forwarding

20.10. How eventing works

20.11. Summary

21. Security, security, security

21.1. Introduction to security

21.2. Security modeling

21.3. Securing the PowerShell environment

21.4. Signing scripts

21.5. Writing secure scripts

21.6. Using the SecureString class

21.7. Summary


© 2014 Manning Publications Co.

About the Technology

Windows PowerShell transformed the way administrators and developers interact with Windows. PowerShell, an elegant dynamic language from Microsoft, lets you script administrative tasks and control Windows from the command line. Because it's a full-featured, first-class Windows programming language, programmers and power-users can now do things in a shell that previously required VB, VBScript, or C#.

About the book

This expanded, revised, and updated Second Edition preserves the original's crystal-clear introduction to PowerShell and adds extensive coverage of v2 features such as advanced functions, modules, and remoting. It includes full chapters on these topics and also covers new language elements and operators, events, Web Services for Management, and the PowerShell Integrated Scripting Environment.

The First Edition's coverage of batch scripting and string processing, COM, WMI, and .NET have all been significantly revised and expanded. The book includes many popular usage scenarios and is rich in interesting examples that will spark your imagination. This is the definitive book on PowerShell v2!

What's inside

  • Batch scripting, string processing, files, and XML
  • PowerShell remoting
  • Application of COM and WMI
  • Network and GUI programming
  • Writing modules and scripts

About the reader

Written for developers and administrators with intermediate level scripting knowledge. No prior experience with PowerShell is required.

About the author

Bruce Payette is a founding member of the PowerShell team at Microsoft. He is codesigner and principal author of the PowerShell language.

combo $59.99 pBook + eBook
eBook $47.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Not just a reference. It’s worth reading cover to cover.

Jason Zions, Microsoft

Unleashes the power in PowerShell.

Sam Abraham, SISCO

Even better than the original.

Tomas Restrepo,

Still the definitive reference.

Keith Hill, Agilent Technologies