我在这里有一个简单的脚本来存档以名称“存档”开头的日志,然后删除那些只留下存档的文件。
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
Run Code Online (Sandbox Code Playgroud)
但是,当脚本运行时,我收到以下错误:
使用“3”个参数调用“Write”的异常:“流太长。” 在 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
有什么建议?