
Contents
About 1 ...................................................................................................................................................................................
Chapter 1: Getting started with PowerShell 2 ....................................................................................................
Section 1.1: Allow scripts stored on your machine to run un-signed 2 ........................................................................
Section 1.2: Aliases & Similar Functions 2 .......................................................................................................................
Section 1.3: The Pipeline - Using Output from a PowerShell cmdlet 3 ........................................................................
Section 1.4: Calling .Net Library Methods 4 ....................................................................................................................
Section 1.5: Installation or Setup 5 ..................................................................................................................................
Section 1.6: Commenting 5 ...............................................................................................................................................
Section 1.7: Creating Objects 6 ........................................................................................................................................
Chapter 2: Variables in PowerShell 7 .....................................................................................................................
Section 2.1: Simple variable 7 ..........................................................................................................................................
Section 2.2: Arrays 7 ........................................................................................................................................................
Section 2.3: List Assignment of Multiple Variables 7 .....................................................................................................
Section 2.4: Scope 8 .........................................................................................................................................................
Section 2.5: Removing a variable 8 ................................................................................................................................
Chapter 3: Operators 9 ..................................................................................................................................................
Section 3.1: Comparison Operators 9 .............................................................................................................................
Section 3.2: Arithmetic Operators 9 ................................................................................................................................
Section 3.3: Assignment Operators 10 ...........................................................................................................................
Section 3.4: Redirection Operators 10 ............................................................................................................................
Section 3.5: Mixing operand types, the type of the left operand dictates the behavior 11 ......................................
Section 3.6: Logical Operators 11 ...................................................................................................................................
Section 3.7: String Manipulation Operators 11 ..............................................................................................................
Chapter 4: Special Operators 13 ..............................................................................................................................
Section 4.1: Array Expression Operator 13 .....................................................................................................................
Section 4.2: Call Operation 13 .........................................................................................................................................
Section 4.3: Dot sourcing operator 13 ............................................................................................................................
Chapter 5: Basic Set Operations 14 .........................................................................................................................
Section 5.1: Filtering: Where-Object / where / ? 14 ......................................................................................................
Section 5.2: Ordering: Sort-Object / sort 14 ..................................................................................................................
Section 5.3: Grouping: Group-Object / group 15 ..........................................................................................................
Section 5.4: Projecting: Select-Object / select 16 ..........................................................................................................
Chapter 6: Conditional logic 17 ..................................................................................................................................
Section 6.1: if, else and else if 17 .....................................................................................................................................
Section 6.2: Negation 17 ..................................................................................................................................................
Section 6.3: If conditional shorthand 18 .........................................................................................................................
Chapter 7: Loops 19 .........................................................................................................................................................
Section 7.1: Foreach 19 .....................................................................................................................................................
Section 7.2: For 19 ............................................................................................................................................................
Section 7.3: ForEach() Method 19 ...................................................................................................................................
Section 7.4: ForEach-Object 20 .......................................................................................................................................
Section 7.5: Continue 21 ...................................................................................................................................................
Section 7.6: Break 21 ........................................................................................................................................................
Section 7.7: While 22 .........................................................................................................................................................
Section 7.8: Do 22 .............................................................................................................................................................
Chapter 8: Switch statement 24 ................................................................................................................................
评论