There are some good responses to the question of how to use Powershell to merge multiple CSV files into one, dropping the header row on all but the first file in this thread.
Kemiller2002's posted answer work well for me in most cases, however when the output file exceeds 2GB I start getting out of memory exception errors. The following error message gets thrown...
Exception of type 'System.OutOfMemoryException' was thrown.
At xxx.ps1:9 char:20
+ $false {$lines | Select -Skip 1}
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], OutOfMemoryException
+ FullyQualifiedErrorId : System.OutOfMemoryException
This is using Powershell 5.1. It doesn't seem to be an issue with the MaxMemoryPerShellMB (that reports to be 2147483647), nor does it appear to be an issue with actual system memory - the last time I ran this there were 33GB of free memory (out of 64GB total) left.
Now the script keeps running, and adding to the file (one of my final files winds up being around 7GB in size), but I can't be certain that it has captured every line in all the files when I see this error popping up.
Any suggestions?
EDIT
I added some output so I could see where the errors are occurring. I'm appending 11 files, varying in size from around 350 MB to 1GB... it is the two files which are around 1GB that cause the errors. One has a reported length of 909,050,983 and the other is 973,429,260.