【发布时间】:2019-12-29 05:21:32
【问题描述】:
当我通过管道将一些对象传递给 select-object -first n 时,它会返回一个数组,除非 n 为 1:
PS C:\> (get-process | select-object -first 1).GetType().FullName
System.Diagnostics.Process
PS C:\> (get-process | select-object -first 2).GetType().FullName
System.Object[]
出于一致性原因,我希望两个管道都返回一个数组。
显然,PowerShell 选择将一个对象作为对象而不是作为数组中的元素返回。
这是为什么呢?
【问题讨论】:
标签: powershell