Merging Object Properties (HPEiLOCmdlets)

I can’t figure out the right approach for merging powershell object properties, for example…

I put together the below to export $iloresults to a csv… however it doesn’t export the complete data because the object item properties vary.

e.g. A server may have a different/additional network adapter(s), array controller, or different number of drives. hostname2 in the below output has an extra property… ‘HP Store Fabric 8Gb Dual Port PCI-e FC HBA – FC’

If i try to export $iloresults it looks like export-csv creates the headers based on the first object so ‘HP Store Fabric 8Gb Dual Port PCI-e FC HBA – FC’ is missing.

My thoughts were to gather all properties from $iloresults items and then somehow pre-create the headers based off of that and if that’s a sensible approach… the noteproperty is out of order so it doesn’t seem like the best way to handle this.

I feel like there’s an easier way of managing this that I’m overlooking. Any ideas? Thanks!

$ilo10connection = Connect-HPEiLO hostname1,hostname2,hostname3 -Credential $iLOcreds -Disablecertificateauthentication $objgen10 = Get-HPEiLOFirmwareInventory -Connection $ilo10connection $iloresults = $( $objgen10 | ForEach-Object { $NewFormatObj = [pscustomobject]@{ Hostname = $PSItem.Hostname IP = $PSItem.IP } $DriveCount = 0 foreach ($PSItem_Item in $PSItem.FirmwareInformation) { if ($PSItem_Item.FirmwareName -eq 'Drive') { $DriveCount += 1 $NewFormatObj | Add-Member -Name "$($PSItem_Item.FirmwareName) $($DriveCount)" -Type NoteProperty -Value $PSItem_Item.FirmwareVersion } else { $NewFormatObj | Add-Member -Name "$($PSItem_Item.FirmwareName)" -Type NoteProperty -Value $PSItem_Item.FirmwareVersion } } $NewFormatObj } #foreach-object ) #scriptblock $iloresults 

Results:

Hostname : hostname1 IP : xxx.xxx.xxx.xxx iLO 5 : 1.39 Dec 05 2018 System ROM : U30 v1.46 (10/02/2018) Intelligent Platform Abstraction Data : 7.2.0 Build 30 System Programmable Logic Device : 0x2A Power Management Controller Firmware : 1.0.4 Power Supply Firmware : 1.00 Innovation Engine (IE) Firmware : 0.1.5.2 Server Platform Services (SPS) Firmware : 4.0.4.288 Redundant System ROM : U30 v1.40 (06/15/2018) Intelligent Provisioning : 3.10.222 Power Management Controller FW Bootloader : 1.1 HPE Smart Storage Battery 1 Firmware : 0.60 HPE Ethernet 1Gb 4-port 331i Adapter - NIC : 20.12.41 HPE Smart Array P408i-a SR Gen10 : 1.65 HP Ethernet 10Gb 2-port 560SFP+ Adapter : 1.1904.0 Embedded Video Controller : 2.5 Drive 1 : 4IYVHPG3 Drive 2 : 4IYVHPG3 Drive 3 : 4IYVHPG3 Drive 4 : 4IYVHPG3 Drive 5 : 4IYVHPG3 Drive 6 : 4IYVHPG3 Drive 7 : 4IYVHPG3 Drive 8 : 4IYVHPG3 Drive Enclosure : 4.21 Hostname : hostname2 IP : xxx.xxx.xxx.xxx iLO 5 : 1.39 Dec 05 2018 System ROM : U30 v1.46 (10/02/2018) Intelligent Platform Abstraction Data : 7.2.0 Build 30 System Programmable Logic Device : 0x2A Power Management Controller Firmware : 1.0.4 Power Supply Firmware : 1.00 Innovation Engine (IE) Firmware : 0.1.5.2 Server Platform Services (SPS) Firmware : 4.0.4.288 Redundant System ROM : U30 v1.40 (06/15/2018) Intelligent Provisioning : 3.10.222 Power Management Controller FW Bootloader : 1.1 HPE Smart Storage Battery 1 Firmware : 0.60 HPE Ethernet 1Gb 4-port 331i Adapter - NIC : 20.12.41 HPE Smart Array P408i-a SR Gen10 : 1.65 HP Store Fabric 8Gb Dual Port PCI-e FC HBA - FC : 08.05.00 HP Ethernet 10Gb 2-port 560SFP+ Adapter : 1.1904.0 Embedded Video Controller : 2.5 Drive 1 : 4IYVHPG3 Drive 2 : 4IYVHPG3 Drive 3 : 4IYVHPG3 Drive 4 : 4IYVHPG3 Drive 5 : 4IYVHPG3 Drive 6 : 4IYVHPG3 Drive 7 : 4IYVHPG3 Drive 8 : 4IYVHPG3 Drive Enclosure : 4.21 Hostname : hostname3 IP : xxx.xxx.xxx.xxx iLO 5 : 1.39 Dec 05 2018 System ROM : U30 v1.46 (10/02/2018) Intelligent Platform Abstraction Data : 7.2.0 Build 30 System Programmable Logic Device : 0x2A Power Management Controller Firmware : 1.0.4 Power Supply Firmware : 1.00 Innovation Engine (IE) Firmware : 0.1.5.2 Server Platform Services (SPS) Firmware : 4.0.4.288 Redundant System ROM : U30 v1.40 (06/15/2018) Intelligent Provisioning : 3.10.222 Power Management Controller FW Bootloader : 1.1 HPE Smart Storage Battery 1 Firmware : 0.60 HPE Ethernet 1Gb 4-port 331i Adapter - NIC : 20.12.41 HPE Smart Array P408i-a SR Gen10 : 1.65 HP Ethernet 10Gb 2-port 560SFP+ Adapter : 1.1904.0 Embedded Video Controller : 2.5 Drive 1 : 4IYVHPG3 Drive 2 : 4IYVHPG3 Drive 3 : 4IYVHPG3 Drive 4 : 4IYVHPG3 Drive 5 : 4IYVHPG3 Drive 6 : 4IYVHPG3 Drive 7 : 4IYVHPG3 Drive 8 : 4IYVHPG3 Drive Enclosure : 4.21 

submitted by /u/lunatix
[link] [comments]

Leave a Reply