title: Compressing files with PowerShell throws OutOfMemory Exception
body: <p>I am using PowerShell v5 and trying to archive the file with the <code>Compress-Archive</code> cmdlet from Microsoft.PowerShell.Archive module:</p>
  
  <pre><code>Compress-Archive -LiteralPath $GLBSourcePathFull -CompressionLevel Optimal -DestinationPath $GLBArchiveFile
  </code></pre>
  
  <p>This worked flawlessly with 3 files, which had the following sizes: <code>16MB</code>, <code>341MB</code> and <code>345MB</code>.</p>
  
  <p>However once it came across the files bigger in size than <code>600MB</code> (approximately), PowerShell threw the following exception:</p>
  
  <pre><code>Exception calling "Write" with "3" argument(s): "Exception of type 'System.OutOfMemoryException' was thrown."
  </code></pre>
  
  <p>The same thing happened with files over <code>1GB</code> in size.</p>
  
  <p>To add more context to my situation, I am trying to zip up the file from the local folder to one of the network locations within my company, however I doubt there is a difference as I tested this on my local PC just to get the same results.</p>
  
  <p>Have you ever encountered this before? Is it trying to read the whole file into memory before outputting the zip instead of writing directly to the disk? Or maybe there is a limit to how much memory PowerShell can use by default?</p>
  
  <p>I know there are a few other solutions like <code>7Zip4powerShell</code> module, but I am not allowed to use anything open source at this point, so I would like to understand the current situation I have and how I could potentially address this.</p>
  
  <p>Thank you for any comments you may have.</p>