Reputation:
I am trying to join two formatted lists of information:
Get-WmiObject -class Win32_OperatingSystem | Format-List Caption
Get-WmiObject -class Win32_Processor | Format-wide Name,Manufacturer,MaxClockSpeed
When I use these two commands I get the following output (Whitespace included):
Caption : Microsoft Windows 8 Pro
Name : Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Manufacturer : GenuineIntel
MaxClockSpeed : 2201
Is there any easy way to join these two lists, thus reducing the whitespace and getting somewhat the same spacing between the colon and the strings?
Upvotes: 1
Views: 153
Reputation: 126762
Create a new object based on the properties selected from each wmi class:
$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
}
Upvotes: 3