Skip to content

Commit c4586ec

Browse files
kilasuitSean Wheeler
authored andcommitted
Adds foreach & where method added in PowerShell v4 (#2139)
Adding details about foreach & where methods being added in PowerShell v4 and that they aren't available downlevel (for historical purposes) and also points to using the Pipeline methods with the resulting Foreach-Object & Where-Object cmdlets
1 parent 4290911 commit c4586ec

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

reference/6/Microsoft.PowerShell.Core/About/about_Arrays.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ for each element of the array.
437437
The following example shows how use the foreach method. In this case the
438438
intent is to generate the square value of the elements in the array.
439439

440+
Please note this method was added in PowerShell v4 and is not available in versions below this.
441+
For prior versions please use the Pipelining method to the ForEach-Object Cmdlet
442+
440443
```powershell
441444
$a = @(0 .. 3)
442445
$a.ForEach({ $_ * $_})
@@ -478,6 +481,9 @@ the element to show after the `Where`
478481
479482
The following example shows how to select all odd numbers from the array.
480483

484+
Please note this method was added in PowerShell v4 and is not available in versions below this.
485+
For prior versions please use the Pipelining method to the Where-Object Cmdlet
486+
481487
```powershell
482488
@(0..9).Where{ $_ % 2 }
483489
```

0 commit comments

Comments
 (0)