none
Combining 2 objects to export-csv RRS feed

  • Question

  • $Object1 = gwmi win32_computersystem -comp $Computer | select Username,@{name='PC Name';expression={$_.Caption}},Manufacturer $Object2 = get-wmiobject -computername $Computer -class win32_bios | select SerialNumber

    I want to take these two objects and combine them to export to one .csv document with the specified information.  Any help would be appreciated.  Thanks.

    Monday, July 31, 2017 10:14 PM

Answers

  • Here's one way:


    Get-WmiObject Win32_ComputerSystem -ComputerName $computer | Select-Object `
      @{Name="ComputerName"; Expression={$_.Caption}},
      Manufacturer,
      @{Name="SerialNumber"; Expression={Get-WmiObject Win32_BIOS -ComputerName $computer | Select-Object -ExpandProperty SerialNumber}}
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by MatchesMalone Tuesday, August 1, 2017 12:38 PM
    Monday, July 31, 2017 10:27 PM
    Moderator

All replies

  • You would want to create a custom  object that combines that information then export the custom object.


    \_(ツ)_/

    Monday, July 31, 2017 10:22 PM
  • Here's one way:


    Get-WmiObject Win32_ComputerSystem -ComputerName $computer | Select-Object `
      @{Name="ComputerName"; Expression={$_.Caption}},
      Manufacturer,
      @{Name="SerialNumber"; Expression={Get-WmiObject Win32_BIOS -ComputerName $computer | Select-Object -ExpandProperty SerialNumber}}
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by MatchesMalone Tuesday, August 1, 2017 12:38 PM
    Monday, July 31, 2017 10:27 PM
    Moderator
  • Works perfect, this is what I was looking for.  Thanks Bill, I appreciate it.

    Tuesday, August 1, 2017 12:54 PM