Author Posts

August 11, 2014 at 10:06 am

$hpILOdrive= Get-HPiLOdriveInfo -Server ***** -Username *****-Password ****

Output:
DRIVE_BAY : {@{DRIVE_BAY=1}, @{DRIVE_BAY=2}, @{DRIVE_BAY=3}, @{DRIVE_BAY=4}}
PRODUCT_ID : {@{PRODUCT_ID=EG0300FBVFL}, @{PRODUCT_ID=EG0300FCSPH}, @{PRODUCT_ID=EG0300FAWHV}, @{PRODUCT_ID=EG0300FBVFL}}
STATUS : {@{STATUS=Ok}, @{STATUS=Ok}, @{STATUS=Ok}, @{STATUS=Ok}}
UID_LED : {@{UID_LED=Off}, @{UID_LED=Off}, @{UID_LED=Off}, @{UID_LED=Off}}
ENCLOSURE_ADDR : 224
FIRMWARE_VERSION : 1.14

August 11, 2014 at 11:24 am

PowerShell's default output type is List for any object with more than 4 properties (or maybe it's "4 or more"; I forget which, off the top of my head.) If you want to force it to use a table instead of a list, you can just pipe your objects to Format-Table. Keep in mind that your screen width is limited, though. Depending on how wide the columns are (particularly if you use the -Autosize switch), the right-most columns might be cut off.

August 11, 2014 at 11:43 am

I am trying to display this a table. The column should be Drive_bay, Product_Id,Status,UID_LED,Enclosure_ADDR, and Firmare_version. Which it does when I Format-table it, but the out put is does not look right.

PS C:\> $hpILOdrive.drive|select Drive_bay,Product_ID

DRIVE_BAY PRODUCT_ID
——— ———-
{@{DRIVE_BAY=1}, @{DRIVE_BAY=2}, @{DRIVE_BAY=3}, @{DRIVE_BAY=4}} {@{PRODUCT_ID=EG0300FBVFL}, @{PRODUCT_ID=EG0300FCSPH}, @{PRODUCT_ID=EG0300FAWHV}, @{PRODUCT_ID=EG0300FBVFL}}
{@{DRIVE_BAY=5}, @{DRIVE_BAY=6}, @{DRIVE_BAY=7}, @{DRIVE_BAY=8}} {@{PRODUCT_ID=EG0300FAWHV}, @{PRODUCT_ID=N/A}, @{PRODUCT_ID=N/A}, @{PRODUCT_ID=N/A}}

[b]PS C:\> $hpILOdrive.drive.Drive_bay[/b]

DRIVE_BAY
———
1
2
3
4
5
6
7
8

PS C:\> $hpILOdrive.drive.PRODUCT_ID

[b]PRODUCT_ID [/b]
———-
EG0300FBVFL
EG0300FCSPH
EG0300FAWHV
EG0300FBVFL
EG0300FAWHV
N/A
N/A
N/A

August 11, 2014 at 11:53 am

Looks like that command returns some objects that are organized a little weirdly. You can work around it with constructed properties (either to Select-Object or Format-Table, depending on your needs), or with loops and New-Object. Try this:

$cleanedUpDrives =
foreach ($drive in $hpILOdrive.drive)
{
    for ($bayIndex = 0; $bayIndex -lt $drive.DRIVE_BAY.Count; $bayIndex++)
    {
        New-Object psobject -Property @{
            DRIVE_BAY        = $drive.DRIVE_BAY[$bayIndex].DRIVE_BAY
            PRODUCT_ID       = $drive.PRODUCT_ID[$bayIndex].PRODUCT_ID
            STATUS           = $drive.STATUS[$bayIndex].STATUS
            UID_LED          = $drive.UID_LED[$bayIndex].UID_LED
            ENCLOSURE_ADDR   = $drive.ENCLOSURE_ADDR
            FIRMWARE_VERSION = $drive.FIRMWARE_VERSION
        }
    }
}

$cleanedUpDrives | Format-Table

August 11, 2014 at 12:03 pm

It's an HP cmdlet. Not sure why the return turn out that way. Your code fixed the issue. T

thanks Jon