-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
Description
When trying to create an archive using Compress-Archive, the cmdlet will always fail if it comes across a file that is currently in use elsewhere, or is unreadable. I have an example of the error it will throw below.
What I would like is a switch which will allow Compress-Archive to skip any in use, or unreadable files and continue without terminating.
I have found this issue in all versions of PS6, and also now in PS7.
ZipArchiveHelper : Could not find file '*file in use*'.
At C:\program files\powershell\6\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:714 char:30
+ ... sArchived = ZipArchiveHelper $subDirFiles.ToArray() $destinationPath ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (*file in use*:String) [Write-Error], FileNotFoundException
+ FullyQualifiedErrorId : CompressArchiveUnauthorizedAccessError,ZipArchiveHelper
New-Object : Exception calling ".ctor" with "1" argument(s): "Stream was not readable."
At C:\program files\powershell\6\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:825 char:38
+ ... $srcStream = New-Object System.IO.BinaryReader $currentFileStream
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand