Maintaining property order with get-member

Question:

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

Answer:

Source:

Maintaining property order with get-member by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply