我有以下几点:
# Compare the 2 lists and return the ones that exist in the top and children (meaning they're redundant).
$redundantUsers = $usersAssignedToThisGroup | where { $usersAssignedToGroupsInThisGroup -contains $_ }
# Build the results to output
$results += New-Object PSObject -property @{
group = $group.name #group assigned out of scope
users = @($redundantUsers)
}
$users = ./MyScript -myParam "something" | Select users
然后我希望能打字
$users[1]
并获取该数组的第一个元素。
但是,我不得不这样做
$users[0].users[1]
我基本上只是想让脚本以一种有用的方式返回数据。