如何从数组对象中提取第一个值times
并data
继续处理其余值直到完成所有值?
PS S:\Files\Scripts> $memory
times data
----- ----
{1548401348221, 1548401358224, 1548401368227, 1548401378227...} {50.47999954223633, 50.47999954223633, 50.47999954223633, 50.47999954223633...}
答案1
一个有点笨拙的方法:
$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '
$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}
$newMemory
times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633