Forum Discussion

Yuansheng Zhang's avatar
Yuansheng Zhang
Copper Contributor
Dec 26, 2020

Access object by index in a pipeline

I can use For loop to calculate array elements as below: $a = 12,34,56,78,99 For ($i=0;$i -lt $a.count-1;$i++) { write-host ($a[$i]-$a[$i+1]) } Is it a way to do it by using pipeline? $a | % { ......