[HeartBeatICStatus] Cannot Handle "Unavailable" (32896)

Mar 17, 2011 at 3:37 PM

ISSUE
While executing Get-VMSummary

The nested vm.ps1 is called, line 214:

                   "Heartbeat"        =  $(if ($_.heartBeat) { [HeartBeatICStatus] $_.Heartbeat} else {$null} )

produces an error if the $_.heartBeat = 32896 (the Heartbeat status in Hyper-V for the VM is "Unavailable"):

Cannot convert value "32896" to type "HeartBeatICStatus" due to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "OK, Error, No_Contact, Lost_Communication".

WORKAROUND (Script Update)
What?: Add an enum option for "Unavailable" with int = 32896
ps1 File: En-us.ps1
Line: 305
Updated Script:

public enum HeartBeatICStatus : int 
{
                Unavailable = 32896,
                No_Contact = 12,
        Lost_Communication = 13,
                        OK = 2,
                     Error = 6
}

Coordinator
Mar 19, 2011 at 12:40 AM

Thanks charles. I'll add this change as the last thing before the new release