Hi,
I try to collect data via powershell and vsphere powercli I would like to pass several stat IDs at once using variable containing my stat ID list.
1) When I do this...
get-stat -entity(get-vmhost $host_id) -stat mem.active.average,sys.resourcecpuusage.average -realtime -maxsamples 1
... It works fine
2) When I do this...
$list = 'mem.active.average'
get-stat -entity(get-vmhost $host_id) -stat $list -realtime -maxsamples 1
... It works fine, I can pass variables and so a stat ID, one at a time.
3) When I do this...
$list = 'mem.active.average,sys.resourcecpuusage.average'
get-stat -entity(get-vmhost $host_id) -stat $list -realtime -maxsamples 1
... It does not work.Powercli returns ...The metric counter "mem.active.average,sys.resourcecpuusage.average" doesn't exist for entity...
I do not understand where the problem is when passing variables, any idea?
That should be
$list = "mem.active.average","sys.resourcecpuusage.average" get-stat -entity(get-vmhost $host_id) -stat $list -realtime -maxsamples 1
You have to give an array of strings.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That should be
$list = "mem.active.average","sys.resourcecpuusage.average" get-stat -entity(get-vmhost $host_id) -stat $list -realtime -maxsamples 1
You have to give an array of strings.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect.
As I will have several stats unknown in advance in my program code I will use the '+=' operator to populate my array.
Thank you.