Powershell - Splitting variable into chunks

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-06-10T15:17:11Z Indexed on 2010/06/10 21:03 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

I have written a query in Powershell interrogating a F5 BIG-IP box through it's iControl API to bring back CPU usage etc.

Using this code (see below) I can return the data back into a CSV format which is fine. However the $csvdata variable contains all the data. I need to be able to take this variable and for each line split each column of data into a seperate variable.

The output currently looks like this: timestamp,"Utilization" 1276181160,2.3282800000e+00

Any advice would be most welcome

$SystemStats = (Get-F5.iControl).SystemStatistics 

### Allocate a new Query Object and add the inputs needed
$Query = New-Object -TypeName iControl.SystemStatisticsPerformanceStatisticQuery
$Query.object_name = $i
$Query.start_time = $startTime
$Query.end_time = 0
$Query.interval = $interval
$Query.maximum_rows = 0 

### Make method call passing in an array of size one with the specified query
$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)

© Stack Overflow or respective owner

Related posts about powershell

Related posts about data