How can I append files using export-csv for PowerShell 2?

Question:


I’ve also tried

The file appears to be overwritten every time. Is there a way to keep adding content to the file?

I get errors

Answer:

The -Append parameter of Export-Csv doesn’t exist until PowerShell 3.0.

One way to work around it in PowerShell 2.0 is to import the existing CSV, create some new rows, append the two collections, and export again. For example, suppose test.csv:

You could append some rows to this CSV file using a script like this:

Run this script and the content of test2.csv will be:

Source:

How can I append files using export-csv for PowerShell 2? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply