Hello,
I have a range of variables that I need to output to a CSV. I need to have the columns in a particular order, as it will be imported into a third party system.
In a foreach loop, I have the following line:
$csvOutfile += New-Object psobject -Property @{Activity=$csvActivity;AssignedTo=$csvAssigned;AuthorizationSource=$csvAuthorizationSource;Comments=$csvComment;InitiatedDateTime=$csvInitiatedDateTime;Location=$csvAddress;Problem=$csvProblem;ReferenceNumber=$csvReference;ScheduledDateTime=$csvInitiatedDateTime}
Outside of the loop, I then append the entire thing to a CSV:
$csvOutfile | export-csv "c:\scripts\results\IPSIntegration.csv"
As is expected behavior, the property columns appear in any old order.
1) How can I change this to a decided order?
2) How can I remove the first line of the CSV which gets added automagically (
| #TYPE System.Management.Automation.PSCustomObject | ||||||||
)
Thanks,
-W