Powershell PSCX Write-Zip "Extra length of extended Zip64 information not allowed"

I had a problem with write-zip: the second time I call Write-Zip with the -Append option, I get an error: The extra length of the extended Zip64 information is not valid.

I am using PSCX 2.1.x.

I had a problem creating a function that, instead of adding a new file, extends the existing zip, if any, to the temp folder, adds a new file to the folder, and then zips all the files in one go. It works ... but it is not very effective.

Is there any solution?

Here is my working function:

Function Add-To-Zip { Param ( [Parameter(Mandatory=$True)] [String] $Path, [Parameter(Mandatory=$True)] [String] $OutputPath, [Parameter(Mandatory=$True)] [String] $TempPath, [Parameter(Mandatory=$False)] [Boolean] $RemoveOriginal = $False ) If (Test-Path $TempPath) { Remove-Item -Path $TempPath -Recurse } New-Item -ItemType Directory -Path $TempPath $paths = @() Copy-Item $Path $TempPath If (Test-Path $OutputPath) { Expand-Archive -Path $OutputPath -OutputPath $TempPath } Get-ChildItem $TempPath | ForEach { $paths += Get-Item $_.FullName } Try { $paths | Write-Zip -OutputPath $OutputPath -Quiet -FlattenPaths -EntryPathRoot $TempPath If ($RemoveOriginal) { Remove-Item -Path $Path } } Catch { Throw "An error occured while adding '$FilePath' to '$ZipPath'." } If (Test-Path $TempPath) { Remove-Item -Path $TempPath -Recurse } } 
+4
source share

Source: https://habr.com/ru/post/1502453/


All Articles