I'm attempting to take data from a CSV file that already exists and put it into a new CSV with additional columns added through PS.
Existing CSV (firstlast.csv)
| First Last |
|---|
| John Doe |
| Jane Doe |
I want to add 2-4 more columns to the CSV with headings that require spaces in them. All the data in each column will be the same though. For example:
NewData.csv
| One Street | First Last | New Address |
|---|---|---|
| X Street | John Doe | Mary St |
| X Street | Jane Doe | Mary St |
Here is what I've tried:
$Name = Import-Csv C:\firstlast.csv | Select-Object -Property *
$test = @{'One Street' = 'X street' ; 'First Last' = $Name ; 'New Address' = 'Mary Street'} | Select-Object -Property One Street, New Address
$test | ConvertTo-Csv -NoTypeInformation | Export-Csv C:\NewData.csv
ConvertTo-Csv(for in-memory CSV data generation) orExport-Csv(for writing to a file).