VMware Cloud Community
RJMoore
Contributor
Contributor
Jump to solution

I can see a properties value, but I can't get the value

i'm trying to access the threshold values for alarms

$alarmDef = Get-AlarmDefinition "Datastore usage*"

$alarmDef.extensiondata.expression.expression.

results in:

Operator        : isAbove
Type            : Datastore
Metric          : VMware.Vim.PerfMetricId
Yellow          : 8500
YellowInterval  :
Red             : 9000
RedInterval     :
DynamicType     :
DynamicProperty :

So I can see the yellow (8500) and red (9000) values from above. so I go

$alarmDef.extensiondata.expression.expression.yellow

but it returns nothing?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The correct path is

$alarmDef.extensiondata.Info.expression.expression

but I assume that was just a typo.

The Expression property points to an array, so even if there is only 1 expression, you still have to use an index.

Like this

$alarmDef.extensiondata.Info.expression.expression[0].Yellow


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

The correct path is

$alarmDef.extensiondata.Info.expression.expression

but I assume that was just a typo.

The Expression property points to an array, so even if there is only 1 expression, you still have to use an index.

Like this

$alarmDef.extensiondata.Info.expression.expression[0].Yellow


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RJMoore
Contributor
Contributor
Jump to solution

Hi Lucd, thanks for the response.

That's odd, I don't have a $alarmDef.extensiondata.Info property, and nothing outputs when i try it. I can only see that data under $alarmdef.ExtensionData.Expression.Expression

and when I try $alarmdef.ExtensionData.Expression.Expression.yellow[0] I get "Cannot index into a null array."

i'm running VMWare vSphere PowerCLI 4.1 U1 build 332441

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The 2nd Expression property is an array, that is the one you need to index.

$alarmdef.ExtensionData.Expression.Expression[0].yellow


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

RJMoore
Contributor
Contributor
Jump to solution

d'oh, that'll teach me to read things properly

thanks!

0 Kudos