An interesting situation I ran into.
Working with VMware PowerCLI to gather performance metrics from vCenter. One of the checks I need to do is to find out the statistics collection level. That returns an array and part of which looks like below. As you may notice that it has a property called “Length” (that should have been named “Duration” but that is beside the point ) and I need to use the values contained in it.
PS C:\Temp> $perfMgr.HistoricalInterval | ft Key SamplingPeriod Name Length Level Enabled --- -------------- ---- ------ ----- ------- 1 300 Past day 86400 1 True 2 1800 Past week 604800 1 True 3 7200 Past month 2592000 1 True 4 86400 Past year 31536000 1 True
I am trying to get to the values contained within the property Length (eg: 86400). Since it shares a name with the property that gives me how big the Array is (in this case 4) I always get that instead of the value in the property Length. Please see below.
PS C:\Temp> $perfMgr.HistoricalInterval.SamplingPeriod[0] 300 PS C:\Temp> $perfMgr.HistoricalInterval.Name[0] Past day PS C:\Temp> $perfMgr.HistoricalInterval.Length[0] 4 PS C:\Temp>
How do I get the value I am looking for?
Thanks in advance.