Contents


preface
about this book
author online
about the authors
acknowledgments
 
Chapter 1 Before you begin
Why you can’t afford to ignore PowerShell
Is this book for you?
How to use this book
Setting up your lab environment
Installing Windows PowerShell
Online resources
Being immediately effective with PowerShell
Chapter 2 Meet PowerShell
Choose your weapon
It’s typing class all over again
Common points of confusion
What version is this?
Lab
Further exploration
Chapter 3 Using the help system
The help system: how you discover commands
Updatable help
Asking for help
Using help to find commands
Interpreting the help
Accessing “about” topics
Accessing online help
Lab
Chapter 4 Running commands
Not scripting, but running commands
The anatomy of a command
The cmdlet naming convention
Aliases: nicknames for commands
Taking shortcuts
Cheating, a bit: Show-Command
Support for external commands
Dealing with errors
Common points of confusion
Lab
Chapter 5 Working with providers
What are providers?
How the filesystem is organized
How the filesystem is like other data stores
Navigating the filesystem
Using wildcards and literal paths
Working with other providers
Lab
Further exploration
Chapter 6 The pipeline: connecting commands
Connect one command to another: less work for you
Exporting to a CSV or an XML file
Piping to a file or a printer
Converting to HTML
Using cmdlets that modify the system: killing processes and stopping services
Common points of confusion
Lab
Chapter 7 Adding commands
How one shell can do everything
About product-specific “management shells”
Extensions: finding and adding snap-ins
Extensions: finding and adding modules
Command conflicts and removing extensions
Playing with a new module
Profile scripts: preloading extensions when the shell starts
Common points of confusion
Lab
Chapter 8 Objects: data by another name
What are objects?
Why PowerShell uses objects
Discovering objects: Get-Member
Object attributes, or “properties”
Object actions, or “methods”
Sorting objects
Selecting the properties you want
Objects until the end
Common points of confusion
Lab
Chapter 9 The pipeline, deeper
The pipeline: enabling power with less typing
How PowerShell passes data down the pipeline
Plan A: pipeline input ByValue
Plan B: pipeline input ByPropertyName
When things don’t line up: custom properties
Parenthetical commands
Extracting the value from a single property
Lab
Further exploration
Chapter 10 Formatting—and why it’s done on the right
Formatting: making what you see prettier
About the default formatting
Formatting tables
Formatting lists
Formatting wide
Custom columns and list entries
Going out: to a file, a printer, or the host
Another out: GridViews
Common points of confusion
Lab
Further exploration
Chapter 11 Filtering and comparisons
Making the shell give you just what you need
Filter left
Comparison operators
Filtering objects out of the pipeline
The iterative command-line model
Common points of confusion
Lab
Further exploration
Chapter 12 A practical interlude
Defining the task
Finding the commands
Learning to use the commands
Tips for teaching yourself
Lab
Chapter 13 Remote control: one to one, and one to many
The idea behind remote PowerShell
WinRM overview
Using Enter-PSSession and Exit-PSSession for one-to-one remoting
Using Invoke-Command for one-to-many remoting
Differences between remote and local commands
But wait, there’s more
Remote options
Common points of confusion
Lab
Further exploration
Chapter 14 Using Windows Management Instrumentation
WMI essentials
The bad news about WMI
Exploring WMI
Choose your weapon: WMI or CIM
Using Get-WmiObject
Using Get-CimInstance
WMI documentation
Common points of confusion
Lab
Further exploration
Chapter 15 Multitasking with background jobs
Making PowerShell do multiple things at the same time
Synchronous versus asynchronous
Creating a local job
WMI, as a job
Remoting, as a job
Getting job results
Working with child jobs
Commands for managing jobs
Scheduled jobs
Common points of confusion
Lab
Chapter 16 Working with many objects, one at a time
Automation for mass management
The preferred way: “batch” cmdlets
The WMI way: invoking WMI methods
The backup plan: enumerating objects
Common points of confusion
Lab
Chapter 17 Security alert!
Keeping the shell secure
Windows PowerShell security goals
Execution policy and code signing
Other security measures
Other security holes?
Security recommendations
Lab
Chapter 18 Variables: a place to store your stuff
Introduction to variables
Storing values in variables
Using variables: fun tricks with quotes
Storing many objects in a variable
More tricks with double quotes
Declaring a variable’s type
Commands for working with variables
Variable best practices
Common points of confusion
Lab
Further exploration
Chapter 19 Input and output
Prompting for, and displaying, information
Read-Host
Write-Host
Write-Output
Other ways to write
Lab
Further exploration
Chapter 20 Sessions: remote control with less work
Making PowerShell remoting a bit easier
Creating and using reusable sessions
Using sessions with Enter-PSSession
Using sessions with Invoke-Command
Implicit remoting: importing a session
Disconnected sessions
Lab
Further exploration
Chapter 21 You call this scripting?
Not programming, more like batch files
Making commands repeatable
Parameterizing commands
Creating a parameterized script
Documenting your script
One script, one pipeline
A quick look at scope
Lab8
Chapter 22 Improving your parameterized script
Starting point
Getting PowerShell to do the hard work
Making parameters mandatory
Adding parameter aliases
Validating parameter input
Adding the warm and fuzzies with verbose output
Lab
Chapter 23 Advanced remoting configuration
Using other endpoints
Creating custom endpoints
Enabling multihop remoting
Digging deeper into remoting authentication
Lab
Chapter 24 Using regular expressions to parse text files
The purpose of regular expressions
A regex syntax primer
Using regex with -Match
Using regex with Select-String
Lab
Further exploration
Chapter 25 Additional random tips, tricks, and techniques
Profiles, prompts, and colors: customizing the shell
Operators: -as, -is, -replace, -join, -split, -in, -contains
String manipulation
Date manipulation
Dealing with WMI dates
Setting default parameter values
Playing with script blocks
More tips, tricks, and techniques
Chapter 26 Using someone else’s script
The script
It’s a line-by-line examination
Lab
Chapter 27 Never the end
Ideas for further exploration
“Now that I’ve read the book, where do I start?”
Other resources you’ll grow to love
Chapter 28 PowerShell cheat sheet
Punctuation
Help file
Operators
Custom property and column syntax
Pipeline parameter input
When to use $_

 
appendix Review labs
index