我有以下简单的PowerShell脚本,用于将一个zip文件夹(包含其他文件夹和仅日志文件)提取到目标位置。
$FolderPath = "C:\Temp\Whatever"
Expand-Archive -Path "$FolderPath\logs.zip" -DestinationPath "$FolderPath\logs"
不幸的是,这会返回一堆像下面这样的错误...
Remove-Item : Cannot find path 'C:\Temp\Whatever\logs\1_Selenium SEPA-Test\Attempt1\1_Start VM's\Release\1_Initialize Agent.log' because it does not exist.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:410 char:46
+ ... $expandedItems | % { Remove-Item $_ -Force -Recurse }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Temp\Whateve...alize Agent.log:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot find path 'C:\Temp\Whatever\logs\1_Selenium SEPA-Test\Attempt1\1_Start VM's\Release\1_Initialize Job.log' because it does not exist.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:410 char:46
+ ... $expandedItems | % { Remove-Item $_ -Force -Recurse }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Temp\Whateve...tialize Job.log:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
还有许多类似的错误。
我可以确认,第一个错误中引用的文件C:\Temp\Whatever\logs\1_Selenium SEPA-Test\Attempt1\1_Start VM's\Release\1_Initialize Agent.log
在等效位置的zip文件夹中确实存在...
脚本完成后,我在指定目录中看到了一个不完整的文件夹。
这里发生了什么?
谢谢,