1

我正在尝试加入两个格式化的信息列表:

Get-WmiObject -class Win32_OperatingSystem | Format-List Caption
Get-WmiObject -class Win32_Processor | Format-wide Name,Manufacturer,MaxClockSpeed

当我使用这两个命令时,我得到以下输出(包括空格):

Caption : Microsoft Windows 8 Pro





Name          : Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Manufacturer  : GenuineIntel
MaxClockSpeed : 2201

有什么简单的方法可以连接这两个列表,从而减少空格并在冒号和字符串之间获得相同的间距?

4

1 回答 1

3

根据从每个 wmi 类中选择的属性创建一个新对象:

$os = Get-WmiObject -class Win32_OperatingSystem | Select-Object Caption
$processor = Get-WmiObject -class Win32_Processor | Select-Object Name,Manufacturer,MaxClockSpeed

New-Object PSObject -Property @{
    Caption = $os.Caption
    ProcessorName = $processor.Name
    ProcessorManufacturer = $processor.Manufacturer
    ProcessorMaxClockSpeed = $processor.MaxClockSpeed
}
于 2013-09-13T16:44:27.717 回答