Powershell Select-Object from array not working

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-06-16T10:16:29Z Indexed on 2010/06/16 10:22 UTC
Read the original article Hit count: 227

Filed under:
|
|

I am trying to seperate values in an array so i can pass them to another function.

Am using the select-Object function within a for loop to go through each line and separate the timestamp and value fields.

However, it doesn't matter what i do the below code only displays the first select-object variable for each line. The second select-object command doesn't seem to work as my output is a blank line for each of the 6 rows.

Any ideas on how to get both values

$ReportData = $SystemStats.get_performance_graph_csv_statistics( (,$Query) )


### Allocate a new encoder and turn the byte array into a string
$ASCII = New-Object -TypeName System.Text.ASCIIEncoding
$csvdata = $ASCII.GetString($ReportData[0].statistic_data) 

$csv2 = convertFrom-CSV $csvdata


$newarray = $csv2 | Where-Object {$_.utilization -ne "0.0000000000e+00" -and   $_.utilization -ne "nan" }


    for ( $n = 0; $n -lt $newarray.Length; $n++)
    {
       $nTime =  $newarray[$n]
       $nUtil =  $newarray[$n]
       $util = $nUtil | select-object Utilization
       $util
       $tstamp = $nTime | select-object timestamp
       $tstamp

    }

© Stack Overflow or respective owner

Related posts about powershell

Related posts about array