Wrong output in PowerShell

44 views Asked by At
$status_message = Get-HPiLoFirmwareversion -Server 172.16.2.210 -Username administrator -Password xxxx -DisableCertificateAuthentication -WarningAction SilentlyContinue |
                  Select-Object -Property STATUS_MESSAGE

if ($status_message -eq '@{STATUS_MESSAGE=OK}') {
    Write-Host "Status OK"
    exit 0
} else {
    Write-Host "error"
    exit 0
}

Write-Host $status_message

but I'm getting the following output:

@{STATUS_MESSAGE=OK}

instead of just "OK".

$status_message = Get-HPiLoFirmwareversion -Server 172.16.2.210 -Username administrator -Password xxxxx -DisableCertificateAuthentication -WarningAction SilentlyContinue

Write-Host $status_message

gives:

IP                   : 172.16.2.210
HOSTNAME             : 
STATUS_TYPE          : OK
STATUS_MESSAGE       : OK
FIRMWARE_DATE        : Sep 23 2016
FIRMWARE_VERSION     : 2.50
LICENSE_TYPE         : iLO Advanced
MANAGEMENT_PROCESSOR : iLO4

It looks like the HP iLO cmdlet is possibly using a Write-Host to output their error message and that may be the issue.

0

There are 0 answers