我有(又一个)PowerShell查询。我在PowerShell中有一个数组,我需要使用remove()和split命令。PowerShell中缺少成员方法
通常你设置一个数组(或变量),并存在上述方法。在下面的$ csv2数组中,两个方法都缺失,我使用get-member cmd进行了检查。
我该如何去使用删除来摆脱nan的线条。另外我如何将列分成两个不同的变量。此刻数组中的每个元素都显示一行,对于每行我需要将其转换为两个变量,每列一个。
时间戳利用
--------- -----------
1276505880 2.0763250000e + 00
1276505890 1.7487730000e + 00
1276505900 1.6906890000e + 00
1276505910 1.7972880000e + 00
1276505920 1.8141900000e + 00
1276505930楠
1276505940楠
1276505950 0.0000000000e + 00
$SystemStats = (Get-F5.iControl).SystemStatistics
$report = "c:\snmp\data" + $gObj + ".csv"
### 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)
$csv2 = convertFrom-CSV $csvdata
$csv2
非常感谢你,让它工作。我读过Arraylists的教程,并没有意识到有什么区别 – Andrew 2010-06-14 10:34:34
@Andrew:的确,ArrayList和Array是完全不同的类型。 'ArrayList'更灵活,但有更多的开销,在应用程序中这可能很重要,但在脚本中不太可能。但是,PSH中的所有内置收集操作都会创建数组。 – Richard 2010-06-14 14:48:15