title: OutOfMemoryException when running my PowerShell script
body: <p>Here's the PowerShell script I am using to add "segment99" to the beginning of all the text files (one by one) within a folder:</p>
  
  <pre><code>Set Environmental Variables:
  
  $PathData = '&lt;&lt;ESB_Data_Share_HSH&gt;&gt;\RwdPnP'
  
  Go to each text file in the specified folder and add header to the file:
  
  Get-ChildItem $PathData -filter 'test_export.txt'|%{
  
  $content = '"segment99" ' + [io.file]::ReadAllText($_.FullName)
  [io.file]::WriteAllText(($_.FullName -replace '\.txt$','_99.txt'),$content)
  
  }
  </code></pre>
  
  <p>This is giving me the following error:</p>
  
  <pre><code>Error: Exception calling "ReadAllText" with "1" argument(s): "Exception of type 'Syste
  Error: m.OutOfMemoryException' was thrown."
  Error: At D:\apps\MVPSI\JAMS\Agent\Temp\JAMSTemp13142.ps1:17 char:51
  Error: + $content = '"segment99" ' + [io.file]::ReadAllText &lt;&lt;&lt;&lt; ($_.FullName)
  Error:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  Error:     + FullyQualifiedErrorId : DotNetMethodException
  Error:
  </code></pre>
  
  <p>I am running this code on a folder that has 20 files, each over 2 GB.</p>
  
  <p>How can I fix this?</p>