Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintaining property order with get-member

I have a query that grabs all the columns from a table then I do some work on it. The problem is I work with the column names for an insert but they are in a different order because of Get-Member. Is there a way to get the property names (column names) and maintain order or re-order the System.Data.DataRow. I must maintain property types.

Commands: $dataColumns = $dataGatherOut | Get-Member -MemberType Property | Select-Object -ExpandProperty Name $dataColumns

Results: PS C:\Windows\system32> $dataColumns

alpha

check

loan


Commands: $dataGatherOut

Results:

check : 1234

loan : Test Values

alpha : 4568

like image 916
Russ960 Avatar asked Mar 15 '13 16:03

Russ960


1 Answers

$dataGatherOut.psobject.properties | select -ExpandProperty Name 
like image 63
mjolinor Avatar answered Sep 27 '22 20:09

mjolinor