Skip to content

Instantly share code, notes, and snippets.

@bobbychopra
Created October 9, 2012 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbychopra/3861585 to your computer and use it in GitHub Desktop.
Save bobbychopra/3861585 to your computer and use it in GitHub Desktop.
Add Date column to an existing csv file
$today = [System.DateTime]::Today.ToString("yyyyMMdd")
Import-Csv -Header Column1,Column2 -Delim ',' 'C:\sample.csv' |
ForEach {
New-Object psobject -Property @{Date=$today;Col1=$_.Column1; Col2=$_.Column2}
} | Select-Object Date,Col1,Col2 | Export-Csv -NoTypeInformation 'C:\sample.csv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment