VMware Cloud Community
jdx495
Contributor
Contributor

Formatting output

I'm a little stuck on the best way to format the output I'm receiving from the vcopsresource module.  I'm not having issues getting the data, but here's what I get:

$serverList = get-vmhost

foreach($server in $serverList){

     $cpuValues += (Get-vCOpsResourceMetric -PSObject $server -metrickey "cpu|usage_average" | select Name, Date, Value)

}

$cpuValues now looks like:

Name                    Date                                        Value

server1               7/17/2014 04:20:12 PM             0.2824919291223

server1               7/17/2014 04:25:12 PM             0.3033928929282

server2               7/17/2014 04:20:12 PM             0.1728391029302

server2               7/17/2014 04:25:12 PM             0.1408383474879

server3               7/17/2014 04:20:12 PM             0.3038910384510

server3               7/17/2014 04:25:12 PM             0.3509399889039

and so on


I want to format the output to be:


Date                                         server1                       server2                          server3

7/17/2014 04:20:12 PM           0.2824919291223     0.1728391029302          0.3038910384510

7/17/2014 04:25:12 PM           0.3033928929282     0.1408383474879          0.3509399889039



I know this is probably very basic but I'm pretty new to powershell/powercli and I can't get out of my head to figure out the best way to re-format the output.  I know I can create a new object but getting all of the values as a new line is giving me fits.  Any advice or comments are appreciated!

0 Kudos
1 Reply
Brian_Graf
Enthusiast
Enthusiast

why not just export like this to CSV and use pivot tables Smiley Happy

Senior Product Manager - Distributed Resource Management | @vBrianGraf
0 Kudos