Table of Contents
Introduction ........................................................................................................................................................ 1
Item 1: Four Cmdlets that are the Keys to Discovery within PowerShell .............................................................. 1
Key #1: Get-Command .................................................................................................................................... 1
Key #2: Get-Help ............................................................................................................................................. 2
Key #3: Get-Member ....................................................................................................................................... 5
Key #4: Get-PSDrive ........................................................................................................................................ 6
PowerShell 2.0 Update..................................................................................................................................... 7
Item 2: Understanding Output ............................................................................................................................ 8
Output is Always a .NET Object ........................................................................................................................ 8
Function Output Consists of Everything That Isn't Captured ............................................................................. 9
Other Types of Output That Can't Be Captured .............................................................................................. 11
Item 3: Know What Objects Are Flowing Down the Pipeline .............................................................................. 12
Item 4: Output Cardinality - Scalars, Collections and Empty Sets - Oh My! ......................................................... 15
Working with Scalars ..................................................................................................................................... 15
Working with Collections ............................................................................................................................... 16
Working with Empty Sets ............................................................................................................................... 17
Item 5: Use the Objects, Luke. Use the Objects! ............................................................................................... 19
Item 6: Know Your Output Formatters .............................................................................................................. 22
Item 7: Understanding PowerShell Parsing Modes ............................................................................................ 31
Item 8: Understanding ByPropertyName Pipeline Bound Parameters................................................................ 35
Item 9: Understanding ByValue Pipeline Bound Parameters.............................................................................. 38
Item 10: Error Handling ..................................................................................................................................... 42
Terminating Errors ......................................................................................................................................... 42
Non-terminating Errors .................................................................................................................................. 42
Error Variables ........................................................................................................................................... 43
Working with Non-Terminating Errors ........................................................................................................... 45
Handling Terminating Errors .......................................................................................................................... 46
Trap Statement .......................................................................................................................................... 46
Try / Catch / Finally .................................................................................................................................... 48
Item 11: Regular Expressions - One of the Power Tools in PowerShell ............................................................... 50
PowerShell 2.0 Update................................................................................................................................... 51