Powershell Script - Sorting the output in a logical order

Good Afternoon,

I currently have a power shell script that extracts data from a CSV source file and writes a new output file.

Script -

CSV Source File:

Output File:

I want to able to the sort the output file into the following order based on the headings below

1. Order Number
2. Please enter either the Plot Number, Garage Number or an area where the work is being done?
3. the following scaffolding which is either

So the new output file will look this

"HV_000024_1150980","189 188 plot ","Handing-Over"
Nick CollinsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
Well, they are rather verbose header names, but that's not too important.  You can specify the order of properties with a Select-Object command.  Change the last line of your script as follows.
$rec | Select-Object "Order Number:",
                      "Please enter either the Plot Number, Garage Number or an area where the work is being done?",
                      "the following scaffolding which is either" |
 Export-Csv -Path D:\iauditor_exports_folder\Email_Process\Test\AuditPlot_HV_Type.txt -NoTypeInformation

Open in new window


Edit:  corrected order
footechCommented:
You could also change the name of headers using something like this.
$rec | Select-Object @{n="OrderNo";e={$_."Order Number:"}},
                     @{n="Location";e={$_."Please enter either the Plot Number, Garage Number or an area where the work is being done?"}},
                     @{n="ScaffoldingType";e={$_."the following scaffolding which is either"}} |
 Export-Csv -Path D:\iauditor_exports_folder\Email_Process\Test\AuditPlot_HV_Type.txt -NoTypeInformation

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.