请帮我解决以下问题。
$emp = $Result | select name,employer | Format-Table -AutoSize
我创建了一个函数aghealth()
,它给出了一些价值。
如何将aghealth
的值添加到$emp
。
答案 0 :(得分:0)
您可以循环遍历$Results
中的值并添加AGHealth值。如果此函数将$Results
值中的一个作为输入,那就太好了。否则你可以使用索引到数组中(假设它返回一个数组......)
$i = 0
foreach($Result in $Results){
[array]$actualResults += New-Object psobject -Property @{
"Name" = $Result.Name
"Employer" = $Result.Employer
# I don't know which of these is most suitable as no idea how aghealth works
# This will not work with duplicates so 2 of these have to go.
"AGHealth" = aghealth($Result.Name)
"AGHealth" = aghealth($Result.Employer)
"AGHealth" = $someVariableThatAlreadyHasAGHealthResults[$i]
}
$i++
}
$actualResults | Format-Table