PowerShell in Depth, Second Edition
Don Jones, Jeffery Hicks, Richard Siddaway
  • October 2014
  • ISBN 9781617292187
  • 744 pages
  • printed in black & white

PowerShell in Depth, Second Edition is the go-to reference for administrators working with Windows PowerShell. Every major technique, technology, and tactic is carefully explained and demonstrated, providing a hands-on guide to almost everything an admin would do in the shell. Written by three experienced authors and PowerShell MVPs, this is the PowerShell book you'll keep next to your monitor—not on your bookshelf!

Table of Contents detailed table of contents

preface

acknowledgments about this book

==

==

==

==

Part 1 PowerShell fundamentals

1. Chapter 1 Introduction

1.1. Who this book is for

1.2. What this book will teach you

1.3. What this book won’t teach you

1.4. Where we drew the line

1.5. Beyond PowerShell

1.6. Ready?

2. Chapter 2 PowerShell hosts

2.1. -bit vs. 64-bit, and administrator vs. not

2.2. The console

2.3. The PowerShell ISE

2.4. Command history buffer vs. PowerShell�s history

2.5. Transcripts

2.6. Summary

3. Chapter 3 Using the PowerShell help system

3.1. The help commands

3.2. Where’s the help?

3.3. Saving help

3.4. Using the help

3.5. “About” help files

3.6. Provider help

3.7. Interpreting command help

3.8. Common parameters

3.9. Summary

4. Chapter 4 The basics of PowerShell syntax

4.1. Commands

4.2. Parameters

4.3. Typing trick: line continuation

4.4. Parenthetical commands and expressions

4.5. Script blocks

4.6. Summary

5. Chapter 5 Working with PSSnapins and modules

5.1. There’s only one shell

5.2. PSSnapins vs. modules

5.3. Loading, autoloading, and profiles

5.4. Using extensions

5.5. Command name conflicts

5.6. Managing module autoloading

5.7. Summary

6. Chapter 6 Operators

6.1. Logical and comparison operators

6.2. Arithmetic operators

6.3. Other operators

6.4. Math operators

6.5. Summary

7. Chapter 7 Working with objects

7.1. Introduction to objects

7.2. Members: properties, methods, and events

7.3. Sorting objects

7.4. Selecting objects

7.5. Filtering objects

7.6. Grouping objects

7.7. Measuring objects

7.8. Enumerating objects

7.9. Importing, exporting, and converting objects

7.10. Comparing objects

7.11. Summary

8. Chapter 8 The PowerShell pipeline

8.1. How the pipeline works

8.2. Parameter binding ByValue

8.3. Pipeline binding ByPropertyName

8.4. Troubleshooting parameter binding

8.5. When parameter binding lets you down

8.6. Nested pipelines

8.7. The pipeline with external commands

8.8. Summary

9. Chapter 9 Formatting

9.1. The time to format

9.2. The formatting system

9.3. The Format cmdlets

9.4. Eliminating confusion and “gotchas”

9.5. Summary

Part 2 PowerShell management

10. Chapter 10 PowerShell Remoting

10.1. The many forms of remote control

10.2. Remoting overview

10.3. Using Remoting

10.4. PSSessions

10.5. Advanced session techniques

10.6. Creating a custom endpoint

10.7. Connecting to non-default endpoints

10.8. Enabling the “second hop”

10.9. Setting up WinRM listeners

10.10. Other configuration scenarios

10.11. Implicit Remoting

10.12. Standard troubleshooting methodology

10.13. Summary

11. Chapter 11 Background jobs and scheduling

11.1. Remoting-based jobs

11.2. WMI jobs

11.3. Scheduled jobs

11.4. Job processes

11.5. Summary

12. Chapter 12 Working with credentials

12.1. About credentials

12.2. Using credentials

12.3. Crazy credentials ideas

12.4. Summary

13. Chapter 13 Regular expressions

13.1. Basic regular expression syntax

13.2. The �match operator

13.3. The Select-String cmdlet

13.4. The Switch statement

13.5. The REGEX object

13.6. Subexpressions and named captures

13.7. Summary

14. Chapter 14 Working with HTML and XML data

14.1. Working with HTML

14.2. Using XML to persist data

14.3. XML basics

14.4. Reading XML files

14.5. Modifying XML

14.6. Creating XML

14.7. Select-XML

14.8. Summary

15. Chapter 15 PSDrives and PSProviders

15.1. Why use PSProviders?

15.2. What are PSProviders?

15.3. What are PSDrives?

15.4. Working with PSDrives

15.5. Transactional operations

15.6. Every drive is different

15.7. Summary

16. Chapter 16 Variables, arrays, hash tables, and script blocks

16.1. Variables

16.2. Built-in variables and the Variable: drive

16.3. Variable commands

16.4. Arrays

16.5. Hash tables and ordered hash tables

16.6. Script blocks

16.7. Summary

17. Chapter 17 PowerShell security

17.1. PowerShell security goals

17.2. PowerShell security mechanisms

17.3. Execution policy

17.4. Blocked files

17.5. The PowerShell security debate

17.6. Summary

18. Chapter 18 Advanced PowerShell syntax

18.1. Splatting

18.2. Defining default parameter values

18.3. Running external utilities

18.4. Expressions in quotes: $($cool)

18.5. Parentheticals as objects

18.6. Increasing the format enumeration limit

18.7. Hash tables as objects

18.8. Summary

Part 3 PowerShell scripting and automation

19. Chapter 19 PowerShell�s scripting language

19.1. Defining conditions

19.2. Loops: For, Do, While, Until

19.3. ForEach

19.4. Break and Continue

19.5. If . . . ElseIf . . . Else

19.6. Switch

19.7. Mastering the punctuation

19.8. Summary

20. Chapter 20 Basic scripts and functions

20.1. Script or function?

20.2. Execution lifecycle and scope

20.3. Starting point: a command

20.4. Accepting input

20.5. Creating output

20.6. “Filtering” scripts

20.7. Moving to a function

20.8. Filter construct

20.9. Summary

21. Chapter 21 Creating objects for output

21.1. Why output objects?

21.2. Syntax for creating custom objects

21.3. Complex objects: collections as properties

21.4. Applying a type name to custom objects

21.5. So, why bother?

21.6. Summary

22. Chapter 22 Scope

22.1. Understanding scope

22.2. Observing scope in action

22.3. Dot sourcing

22.4. Manipulating cross-scope elements

22.5. Being private

22.6. Being strict

22.7. Summary

23. Chapter 23 PowerShell workflows

23.1. Workflow overview

23.2. Workflow basics

23.3. General workflow design strategy

23.4. Example workflow scenario

23.5. Writing the workflow

23.6. Workflows vs. functions

23.7. Specific workflow techniques

23.8. Running a workflow

23.9. A practical example

23.10. Invoke-AsWorkflow

23.11. PSWorkflowSession

23.12. Troubleshooting a workflow

23.13. Summary

24. Chapter 24 Advanced syntax for scripts and functions

24.1. Starting point

24.2. Advanced parameters

24.3. Variations on parameter inputs

24.4. Parameter aliases

24.5. Parameter validation

24.6. Parameter sets

24.7. WhatIf and Confirm parameters

24.8. Verbose output

24.9. Summary

25. Chapter 25 Script modules and manifest modules

25.1. Making a script module

25.2. Exporting module members

25.3. Making a module manifest

25.4. Creating dynamic modules

25.5. Summary

26. Chapter 26 Custom formatting views

26.1. Object type names

26.2. Getting view templates

26.3. Starting a view file

26.4. Adding view types

26.5. Importing view data

26.6. Using named views

26.7. Going further

26.8. Summary

27. Chapter 27 Custom type extensions

27.1. What are type extensions?

27.2. Creating and loading a type extension file

27.3. Making type extensions

27.4. A complete example

27.5. Updating type data dynamically

27.6. Get-TypeData

27.7. Remove-TypeData

27.8. Summary

28. Chapter 28 Data language and internationalization

28.1. Internationalization basics

28.2. Adding a data section

28.3. Storing translated strings

28.4. Testing localization

28.5. Summary

29. Chapter 29 Writing help

29.1. Comment-based help

29.2. Writing About topics

29.3. XML-based help

29.4. Summary

30. Chapter 30 Error handling techniques

30.1. About errors and exceptions

30.2. Using $ErrorActionPreference and �ErrorAction

30.3. Using �ErrorVariable

30.4. Using $?

30.5. Using $Error

30.6. Trap constructs

30.7. Try…​Catch…​Finally constructs

30.8. Summary

31. Chapter 31 Debugging tools and techniques

31.1. Debugging: all about expectations

31.2. Write-Debug

31.3. Breakpoints

31.4. Using Set-PSDebug

31.5. Remote debugging

31.6. Debugging workflows

31.7. Debugging in third-party editors

31.8. Summary

32. Chapter 32 Functions that work like cmdlets

32.1. Defining the task

32.2. Building the command

32.3. Parameterizing the pipeline

32.4. Adding professional features

32.5. Error handling

32.6. Making it a function and adding help

32.7. Creating a custom view

32.8. Creating a type extension

32.9. Making a module manifest

32.10. Summary

33. Chapter 33 Tips and tricks for creating reports

33.1. What not to do

33.2. Working with HTML fragments and files

33.3. Sending email

33.4. Summary

Part 4 Advanced PowerShell

34. Chapter 34 Working with the Component Object Model (COM)

34.1. Introduction to COM objects

34.2. Instantiating COM objects in PowerShell

34.3. Accessing and using COM objects’ members

34.4. PowerShell and COM examples

34.5. Summary

35. Chapter 35 Working with .NET Framework objects

35.1. Classes, instances, and members

35.2. NET Framework syntax in PowerShell

35.3. NET support in PowerShell

35.4. Accessing static members

35.5. Finding the right framework bits

35.6. Creating and working with instances

35.7. Summary

36. Chapter 36 Accessing databases

36.1. Native SQL vs. OLEDB

36.2. Connecting to data sources

36.3. Querying data

36.4. Adding, changing, and deleting data

36.5. Calling stored procedures

36.6. A module to make it easier

36.7. Summary

37. Chapter 37 Proxy functions

37.1. The purpose of proxy functions

37.2. How proxy functions work

37.3. Creating a basic proxy function

37.4. Adding a parameter

37.5. Removing a parameter

37.6. Turning it into a function

37.7. Summary

38. Chapter 38 Building a GUI

38.1. WinForms via PowerShell Studio

38.2. Windows Presentation Foundation (WPF) and ShowUI

38.3. WinForms vs. WPF

38.4. Ideas for leveraging a GUI tool

38.5. Summary

39. Chapter 39 WMI and CIM

39.1. What is WMI?

39.2. WMI cmdlets

39.3. CIM cmdlets

39.4. CIM sessions

39.5. “Cmdlets over objects”

39.6. Summary

40. Chapter 40 Working with the web

40.1. Getting data from the web

40.2. Using web sessions

40.3. Working with web responses

40.4. Using REST services

40.5. Using SOAP web services

40.6. Just in case

40.7. Summary

41. Chapter 41 Desired State Configuration

41.1. What is DSC?

41.2. DSC architecture

41.3. Writing the configuration script

41.4. Getting the configuration to the computer

41.5. Creating and testing a DSC pull server

41.6. Writing DSC resources

41.7. DSC vs. Group Policy

41.8. Summary

Appendix A: Best practices

PowerShell Web Access
PowerShell versions

index

© 2014 Manning Publications Co.

About the book

A Windows admin using PowerShell every day may not have the time to search the net every time he or she hits a snag. Wouldn't it be great to have a team of seasoned PowerShell experts ready to answer even the toughest questions? That's what you get with this book.

PowerShell in Depth, Second Edition is the go-to reference for administrators working with Windows PowerShell. Every major technique, technology, and tactic is carefully explained and demonstrated, providing a hands-on guide to almost everything an admin would do in the shell. Written by PowerShell MVPs Don Jones, Jeffrey Hicks, and Richard Siddaway, each valuable technique was developed and thoroughly tested, so you'll be able to consistently write production-quality, maintainable scripts while saving hours of time and effort.

What's inside

  • Automating tasks
  • Packaging and deploying scripts
  • Introduction to Desired State Configuration
  • PowerShell security
  • Covers PowerShell version 3 and later

About the reader

This book assumes you know the basics of PowerShell.

About the author

Don Jones, Jeffery Hicks, and Richard Siddaway are Microsoft MVPs, trainers, and administrators. Collectively, they've authored nearly three dozen books on PowerShell and Windows administration.


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

FREE domestic shipping on three or more pBooks