Alec Thomas
Alec Thomas

Reputation: 186

How to uppercase a unique identifier when exporting to CSV with Powershell

When exporting a SQL dataset that contains a unique identifier in the first column, Powershell/.NET is transforming the GUID to lowercase. This is to be used in a down stream system that is requiring the GUID's to be uppercased. What is the cleanest way to get the GUID to export uppercased?

Here is the export portion that we are currently using:

$DataSet.Tables[0] | Export-Csv $OuputFile -NoTypeInformation

Upvotes: 1

Views: 361

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174825

Pipe the data via ForEach-Object and modify the relevant property value before exporting:

$DataSet.Tables[0] |ForEach-Object {
  $_.'Item UUID' = $_.'Item UUID'.ToString().ToUpper()
  $_
} |Export-Csv $OuputFile -NoTypeInformation

Upvotes: 3

Related Questions