Multivalue to array


i'm trying performance data hyper-v cluster system center virtual machine manager 2012 r2 via powershell csv file anlyzed in excel.

i have command:

get-scvmhostcluster -name mam-hv01 | get-scperformancedata -performancecounter cpuusage -timeframe day

this produces:

name               : mam-hv01-n01.mbn1.net  performancehistory : {26, 26, 24, 19...}  timeframe          : day  performancecounter : cpuusage  scope              :  timesamples        : {03.12.2013 12:00:00, 03.12.2013 13:00:00, 03.12.2013 14:00:00, 03.12.2013 15:00:00...}  serverconnection   : microsoft.systemcenter.virtualmachinemanager.remoting.serverconnection  id                 : 9e459a2c-79b7-4ac7-a759-eb1dbd3a0ade  isviewonly         : false  objecttype         : none  markedfordeletion  : false  isfullycached      : true

as can see values need in timesamples , performancehistory, seem in sort of multivalue string or something. how can array , ultimatly csv, 1 column timesamples , 1 column corresponding values timesamples?

ultimately want columns other available performance counters are: memoryusage , storageiopsusage, 

assuming columns match correctly:

$dataobject = get-scvmhostcluster -name mam-hv01 | get-scperformancedata -performancecounter cpuusage -timeframe day $results = @() $numberofitems = $dataobject.timesamples.count for($counter = 0; $counter -lt $numberofitems; $counter++;) {   #get time stamp   $timestamp = $dataobject.timesamples[$counter]   #get matching performance history object   $performancedata = $dataobject.performancecounter[$counter]   $results += new-object -type psobject -props @{      "timestamp" = $timestamp,      "performancedata" = $performancedata   } }  $results | convertto-csv >> "c:\folder\filename.csv"

i've got psobject bit wrong, might work extent. if wanted include other counters similar process adding them existing fields, or more grabbing other dataobjects , processing them in same loop.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607