问题描述
我在这里有一个简单的脚本来存档以名称存档"开头的日志,然后删除那些只留下存档的文件.
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:
使用3"个参数调用Write"的异常:流太长."在C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:809字符:29
+ ... $destStream.Write($buffer, 0, $numberOfBytesRead)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullQualifiedErrorId : IOException
有什么建议吗?
推荐答案
Compress-Archive 依赖 Microsoft .NET Framework API System.IO.Compression.ZipArchive 来压缩文件,使用 Compress 可以压缩的最大文件大小- 存档当前为 2 GB.这是底层 API 的限制.
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.
请参阅:这里
这篇关于Compress-Archive 命令返回“异常:流太长".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!