Loading Text Files (Fast)

by Oct 26, 2021

If you need to load large text files and are using Get-Content, then chances are you can save a lot of time.

If you are not immediately processing the results emitted by Get-Content via a pipeline, you may want to add the parameter -ReadCount 0. This can speed up reading text files by factor 100.

Without this parameter, Get-Content emits each text line separately. That’s perfect if these lines are processed by a pipeline. But it is a waste of time if you want to store the text in a variable and use other ways of processing, for example a classic foreach loop.


Twitter This Tip! ReTweet this Tip!