powershell - Multiple WMI queries into a single Format-Table -


I think what type of help I need is putting multiple WMI queries in a single table.

For example:

  Get-WMIObject Win32_Processor-ComputerName $ server | Format-Table: PSComputerName, DataWidth   

This is fine, but I also need a single line of OS version, for that I have to query Win32_OperatingSystem and remove the caption property. So how do I get two different WMI queries in the same table?

I have tried the following:

  $ os = gmi Win32_Processor- Compute name $ server $ cpu = Gmi Win32_OperatingSystem -Computername $ server   

Then I can get the properties that I want easily:

$ os.PSComputerName, $ cpu.caption, $ os DataWidth

But what I've read, the format table accepts data from only one pipeline. It does not seem to have to do with (variable). (Property)

Ideally, I am able to run as a last semitic in script block:

  format-table $ OSPS compute, $ cpu. Caption, $ osadatide   

But of course, the format table always comes at the end of a line, never at the beginning.

You can use common pipelines for one of the objects and the other: $ os = gwmi Win32_OperatingSystem- Compute's name $ server gwmi Win32_Processor- ComputerName $ server | Format-Table @ {name = "ComputerName"; Exp = {$ os.PSComputerName}}, captions, datawidth

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -