ForEach Method

suggest change

Instead 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents