PowerShell Gotchas
Learn more about PowerShell by examining some of its most strange behaviors.
What you'll learn
PowerShell is the de facto standard for automation and administration on Windows systems. The central design mantra in PowerShell is Think-Type-Get. That is: Think what you want, Type it, and Get the results. Unfortunately this mantra doesn't always work - PowerShell combines concepts from other languages (Perl, Python, and VBScript for example) and borrows ideas from other platforms (like pipelining in Bash). This creates an experience that feels familiar, but fails to behave consistently with our experiences. This creates "gotchas." In this course, we will analyze some specific cases of PowerShell's strange behavior in order to better understand how and why PowerShell works the way it does.
Table of contents
- Paths in PowerShell 1m
- Gotcha #1: ~ 3m
- ~ and PowerShell Providers 3m
- ~ is Fragile 1m
- ~ and PowerShell Scripts 1m
- Gotcha #1: Workarounds 2m
- Gotcha #1: Change your Thinking 1m
- Gotcha #2: Current Location vs. Current Directory 4m
- PowerShell is A Windows Process 2m
- PowerShell Location and Windows Current Directory 2m
- Gotcha #2: Workaround 3m
- Gotcha #2: Change your Thinking 1m
- Summary 2m
- Pipelines are Awesome (Except when They're Not) 2m
- Gotcha #3: Expressing Yourself in an Argument 2m
- Pipeline Execution Order and Expressions 1m
- (Expressions as Cmdlet Arguments) 2m
- Gotcha #3: Change your Thinking 1m
- Gotcha #4: Return All The Things! 2m
- Every Statement is A Pipeline 1m
- Errant Output can Cause Problems 3m
- Swallowing Pipeline Output 2m
- Gotcha #4: Chane your Thinking 1m
- Gotcha #5: Iterating Nothing 2m
- Undefined Variables are $null, and $null will Pipe 2m
- Oddity with The foreach statement in PowerShell V3 2m
- Enforcing Best Practices with PowerShell Strict Mode 2m
- Gotcha #5: Change your Thinking 1m
- Summary 2m
- Meet The King of Automation 1m
- Gotcha #6: Foreign Dialects 3m
- The String Interpretation Stack 2m
- Backticks and Non-interpolated Strings 3m
- Escape Characters 3m
- Gotcha #6: Change your Thinking 1m
- Gotcha #7: Interpolating Scope 2m
- PowerShell Global and Local Scope 3m
- Errant Scoping in Interpolated Strings 3m
- Giving PowerShell A Clue 1m
- Gotcha #7: Change your Thinking 1m
- Summary 1m
- Introduction 1m
- Gotcha #8: -or and/or -and 2m
- Operator Precedence 2m
- Operator Precedence - PowerShell vs Almost Everywhere Else 2m
- Making Logic Logical 1m
- Gotcha #8: Change your Thinking 1m
- Gotcha #9: Unequal Equality 2m
- Why $a equals $b 2m
- Why $b does not equal $a 1m
- Null references and Strings 1m
- Gotcha #9: Change your Thinking 1m
- Summary 1m