Forum Discussion
Yuansheng Zhang
Dec 26, 2020Copper Contributor
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 | % { ... }
how about if array is [pscustomobject]@{ ... } ?
Thanks.
1 Reply
- farismalaebSteel Contributor