2017-12-14 21 views
1

단일 문서를 제외하고 모든 항목이 들어있는 폴더를 압축 한 다음 압축 된 폴더를 새 위치로 출력하려고합니다. 내가 그렇게 할 때, 나는 '오직 내가 할 수있는 오류는 내부 PowerShell을 모듈에서 발생하는 것으로 보인다PowerShell에서 디렉터리를 압축 할 때 Remove-Item 오류가 발생했습니다.

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 

내가 제거-항목 어디서나 내 코드에 있고,없는 제거-항목 오류를 얻을 그것을 일으킨 원인을 찾아 내십시오.

this 스레드에서 제안한 것처럼 불행히도 대체 압축 라이브러리를 쉽게 다운로드 할 수없는 위치에 있습니다.

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 

이 오류는 성공적으로 내 원하는 위치에 압축 폴더를 출력에서 ​​저를 방해 :

여기에 관련 코드입니다. 이 오류의 원인 및/또는 해결을 위해 무엇을 변경해야합니까?

답변

0

내 경우에는 Expand-Archive을 사용하면 정확히 Remove-Item 오류가 발생합니다. 이 코드는 오류 던지고 : 조금 실험 후

Expand-Archive $zipFileName -DestinationPath $targetFolder 

를, 그것은 -Force 매개 변수를 추가하여 문제를 해결하는 것이 밝혀졌다 :

Expand-Archive $zipFileName -DestinationPath $targetFolder -Force 

수동으로 추출 된 아카이브가 제대로 것으로 확인 점검 추출.

나는 아직도 어떤 버그가 있는지 알지 못한다. 그러나 -Force 매개 변수를 추가하면 필자의 경우 문제가 해결되었습니다. 어쩌면 그것은 당신의 경우에도 효과가있을 것입니다.