Home > Software engineering >  How to uppercase a unique identifier when exporting to CSV with Powershell
How to uppercase a unique identifier when exporting to CSV with Powershell

Time:01-20

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

CodePudding user response:

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
  •  Tags:  
  • Related