當(dāng)我們嘗試通過(guò)管道將數(shù)據(jù)導(dǎo)出到其他函數(shù)時(shí),我們?cè)赑owerShell中觀察到一些奇怪的行為。示例代碼:$Array = @()$Obj1 = [PSCustomObject]@{ Member1 = 'First' Member2 = 'Second'}$Obj2 = [PSCustomObject]@{ Member1 = 'First' Member2 = 'Second' Member3 = 'Third'}$Array = $Obj1, $Obj2$Array | Out-GridView -Title 'Not showing Member3'$Array = $Obj2, $Obj1$Array | Out-GridView -Title 'All members correctly displayed'在上面的示例中,您可以看到,當(dāng)?shù)谝粋€(gè)對(duì)象僅包含2時(shí),即使第二個(gè)對(duì)象具有3 properties,Out-GridViewCmdLet(和其他對(duì)象)也僅顯示2 。但是,當(dāng)數(shù)組中的第一個(gè)對(duì)象包含3個(gè)對(duì)象時(shí),它會(huì)正確顯示所有對(duì)象。propertiespropertiesproperties有沒(méi)有解決的辦法?因?yàn)闊o(wú)法預(yù)先預(yù)測(cè)properties某個(gè)對(duì)象上將有多少個(gè)對(duì)象,以及最多的對(duì)象properties將是中的第一個(gè)對(duì)象array。
并非顯示所有屬性
千巷貓影
2019-12-06 12:36:08