几天前,我正在尝试格式化与问题相关的 PSObject。我的对象如下所示:
New-Object PSObject -Property @{
"Version"= $winVersion.Caption
"Processor Name" = $processorInfo.Name
"Processor Manufacturer" = $processorInfo.Manufacturer
"Processor Max Clock Speed" = $processorInfo.MaxClockSpeed
} |format-list
上面给出了以下输出:
Processor Manufacturer : GenuineIntel
Processor Max Clock Speed : 2201
Version : Microsoft Windows 8 Pro
Processor Name : Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
然而,这:
New-Object PSObject -Property @{
"Windows Version"= $winVersion.Caption
"Processor Name" = $processorInfo.Name
"Processor Manufacturer" = $processorInfo.Manufacturer
"Processor Max Clock Speed" = $processorInfo.MaxClockSpeed
} |format-list
给出以下输出:
Processor Manufacturer : GenuineIntel
Processor Max Clock Speed : 2201
Processor Name : Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Windows Version : Microsoft Windows 8 Pro
没什么大不了的,但我想知道为什么格式会发生变化?它似乎不是按字母顺序排列的。此外,我尝试使用 Sort-Object(来自 AZ)对对象进行排序,但无济于事。它与字符串有关吗?