http://powershelltricks.blogspot.com/2012/07/sort-dataset-dataview.html
DataTable DataView Sort
$dt = new-object System.Data.dataTable
$dt.Columns.Add("Name") | Out-Null
$dt.Columns.Add("size", [int]) | Out-Null
$row = $dt.NewRow()
$row["Name"] = "Test"
$row["size"] = 10
$dt.Rows.Add($row)
$row = $dt.NewRow()
$row["Name"] = "Test 2"
$row["size"] = 20
$dt.Rows.Add($row)
$dw = New-Object System.Data.DataView($dt)
$dw.Sort="size DESC"
$dw | Format-Table -AutoSize # Or $dw | Out-GridView
$dt.Close
$dw.close
No comments:
Post a Comment
Note: only a member of this blog may post a comment.