ForEach Method
suggest changeInstead of the ForEach-Object
cmdlet, the here is also the possibility to use a ForEach
method directly on object arrays like so
(1..10).ForEach({$_ * $_})
or - if desired - the parentheses around the script block can be omitted
(1..10).ForEach{$_ * $_}
Both will result in the output below
1
4
9
16
25
36
49
64
81
100
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents