I am currently writing a new line to a CSV-file each time I successfully/unsuccessfully execute a command in my script with the export-csv command. The resulting file is a logfile.
I would like to store all of this output into some kind of variable and write it all in one go at the end of the script.. This sounds far more efficient and clever as I am currently opening/writing/closing my csv file hundreds of time on each run..
But how would I do this?
Any help is greatly appreciated as always!!
Seems easy enough. Just create an empty array to hold your log lines before you start:
Then instead of adding to the csv file, add to the array:
If you’re doing that a whole bunch of times, an arraylist might be better than an array:
then:
Then at the end (for either one):