Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compress-Archive command returns "Exception: Stream was too long."

I have a simple script here to archive logs that begin with the name "Archive" then delete those files leaving only the archive.

cd L:\

$Source =  Get-ChildItem L:\ | Where{$_.Name -match "^Archive.*\.evtx$"} |Get-ChildItem -name

$CurrentDate = get-date -Format M.d.yyyy

$Destination = "$CurrentDate.zip"

Compress-Archive -Path $Source -destinationpath $Destination

rm L:\$Source

However, I receive the below error when the script runs:

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:809 char:29
+ ... $destStream.Write($buffer, 0, $numberOfBytesRead)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException

Any suggestions?

like image 512
selachka Avatar asked Sep 19 '16 16:09

selachka


1 Answers

Compress-Archive relies upon the Microsoft .NET Framework API System.IO.Compression.ZipArchive to compress files, the maximum file size that you can compress by using Compress-Archive is currently 2 GB. This is a limitation of the underlying API.

Please see more at : here

like image 135
Deepak Tiwari Avatar answered Sep 28 '22 11:09

Deepak Tiwari