I'm attempting to zip up a folder with everything inside except for a single document, then output that compressed folder to a new location. However, when I do so, I get a Remove-Item error
Remove-Item : Cannot find path 'C:\Folder\123\12345\12345-A.zip' because it does not exist.
At C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:233 char:21
+ ... Remove-Item -LiteralPath $DestinationPath -Force -Recurse ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Folder...12345\12345-A.zip:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
I don't have Remove-Item anywhere in my code, and the error appears to originate from an internal PowerShell module, only I can't figure out what caused it.
Unfortunately I'm in a position where I can't readily download alternative compressing libraries, as suggested in this thread.
Here is the relevant code:
Copy-Item -path $path -destination "$destination\$doc_project_folder\$doc_project_rev\"
Write-Host "Copied to $destination\$doc_project_folder\$doc_project_rev"
Get-ChildItem $document_hash[$doc] | Where { $_.Name -notin $docs_to_exclude} |
Compress-Archive -DestinationPath "$destination\$doc_project_folder\$doc_project_rev\$doc_number.zip" -compressionlevel fastest
This error is preventing me from successfully outputting the compressed folder to my desired location. What is causing this error, and/or what should I change to solve it?