title: Can you compress files on a network share using PowerShell without downloading them to the client?
body: <p>I have a network share hosted by a server (\SERVER) which is being accessed by other servers/clients. </p>
  
  <pre><code>\\SERVER\SHARE\Folder\File
  </code></pre>
  
  <p>If I wanted to compress <code>Folder</code> and everything in it, is it possible to do using PowerShell WITHOUT having the files be downloaded to the machine that is running the command? </p>
  
  <p>The files in question are large, and there is not enough room on the C drive to download and compress the files on the client. So for example if I navigated to the network share from the client using Windows File Explorer, and selected the folder to compress, it would start downloading the files to the client and then fail due to insufficient free space on the client.</p>
  
  <p><em>What about PowerShell's Invoke-Command Option?</em></p>
  
  <p>I do have the option to Invoke-Command from the client to the server, however, the C drive of \SERVER is to small to handle the request as well. There is a D drive (which hosts the actual \SHARE), which has plenty of space though. I would have to tell PowerShell to compress files on that drive somehow instead of the default which would be the C drive.</p>
  
  <p><em>Error when running the below PowerShell Command</em></p>
  
  <pre><code>Compress-Archive -Path "\\SERVER\SHARE\Folder" -DestinationPath "\\SERVER\SHARE\OtherFolder\Archive.zip"
  </code></pre>
  
  <blockquote>
    <p>Exception calling "Write" with "3" argument(s): "Stream was too long."
    At
    C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:820
    char:29
    + ...                     $destStream.Write($buffer, 0, $numberOfBytesRead)
    +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : IOException</p>
  </blockquote>