假設最簡潔的方式:搜索哈希表的數組,一個關鍵
$columnArray = @(
@{Name='COL_A';Type=[int];[email protected]()},
@{Name='COL_B';Type=[string];[email protected]()},
@{Name='COL_C';Type=[datetime];[email protected]()}
)
使用Where-Object
命令得到COL_B
的Measurements
數組:
($Fields | ? { $_.Name -eq 'COL_B' }).Measurements
是否有更多 - 簡潔的方式做到這一點?一套嵌套的PSCustomObject
是更好的方法嗎?
爲什麼不
-property
標誌的對象'$ columnHashtable = @ {爲col_a = @ {類型= [INT];三圍= @()}; COL_B = @ {類型= [字符串];三圍= @()}; COL_C = @ {類型= [日期時間];三圍= @()}}'?你可以這樣做:'$ columnHashtable.COL_B.Measurements'。 – PetSerAl'$ columnArray | %{New-Object PSObject -property $ _} | ? {$ _。名稱-eq'COL_B'} |選擇度量--ExpandProperty度量' –
@DaveSexton'Select -ExpandProperty Measurements' – Matt