Powershell-批量提取档案-文件列表

问题描述

我需要从档案7z中提取日志文件,仅在过去1.5天修改。 所以我使用命令:

'md C:\TEMP\BL -ErrorAction SilentlyContinue

$Path = 'C:\TEMP\BL'

$archives = @( 
"C:\Users\dark_\AppData\Roaming\Apple Computer\Logs\Logs.7z" 
"C:\Users\dark_\AppData\Local\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AppData\Indexed DB\edb.7z"
"C:\ProgramData\GOG.com\galaxy\logs\galaxyClientService.7z")

$files =@()

$archives |gci | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-1.5) } | Select-Object Fullname,LastWriteTime | Export-CSV -Delimiter ';'-NoTypeinformation -Path C:\TEMP\BL\1.csv

$files =  Import-Csv -Delimiter ';' -Path C:\TEMP\BL\1.csv 


$files | Select-Object FullName | Out-File C:\TEMP\BL\adresy.txt


foreach($line in [System.IO.File]::ReadLines("C:\TEMP\BL\adresy.txt"))
{

Write-Output ""from loop " $line"
  & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log -r;
  
}

$text = Get-Content  C:\TEMP\BL\*.log -tail 2 -ErrorAction SilentlyContinue
Write-Output "" "" $text ""


`
 

但是我仅成功提取一个文件,其余显示错误输出为:

from
loop
 

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
1 file,1183794 bytes (1157 KiB)

Extracting archive: hurt.log
7z.exe : ERROR: hurt.log
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (ERROR: hurt.log:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
Can not open the file as archive

Can't open as archive: 1
Files: 0
Size:       0
Compressed: 0

from
loop
 FullName                                                                                              

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
7z.exe : 
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
ERROR: Nie moľna odnale«† okrelonego pliku.
FullName                                                                                              
System ERROR:
Nie moľna odnale«† okrelonego pliku.

from
loop
 --------                                                                                              
7z.exe : 
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
Command Line Error:
UnkNown switch:
--------                                                                                              

from
loop
 C:\Users\dark_\AppData\Roaming\Apple Computer\Logs\Logs.7z                                            

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
7z.exe : 
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
ERROR: Nie moľna odnale«† okrelonego pliku.
C:\Users\dark_\AppData\Roaming\Apple Computer\Logs\Logs.7z                                            
System ERROR:
Nie moľna odnale«† okrelonego pliku.

from
loop
 C:\Users\dark_\AppData\Local\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AppData\Indexed DB\edb.7z

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
1 file,3224 bytes (4 KiB)

Extracting archive: C:\Users\dark_\AppData\Local\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AppData\Indexed DB\edb.7z
--
Path = C:\Users\dark_\AppData\Local\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AppData\Indexed DB\edb.7z
Type = 7z
Physical Size = 3224
Headers Size = 122
Method = LZMA2:768k
Solid = -
Blocks = 1

Everything is Ok

Size:       524293
Compressed: 3224

from
loop
 C:\ProgramData\GOG.com\galaxy\logs\galaxyClientService.7z                                             

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
7z.exe : 
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
ERROR: Nie moľna odnale«† okrelonego pliku.
C:\ProgramData\GOG.com\galaxy\logs\galaxyClientService.7z                                             
System ERROR:
Nie moľna odnale«† okrelonego pliku.

from
loop
 

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
1 file,remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
Can not open the file as archive

Can't open as archive: 1
Files: 0
Size:       0
Compressed: 0

from
loop
 

7-Zip 20.00 alpha (x64) : copyright (c) 1999-2020 Igor Pavlov : 2020-02-06

Scanning the drive for archives:
7z.exe : ERROR: hurt.log
At C:\Users\dark_\OneDrive - PDF Slawex\Skrypty\testowy2.ps1:24 char:3
+   & "C:\Program Files\7-Zip\7z.exe" e "$line" -aoa -oC:\TEMP\BL *.log ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (ERROR: hurt.log:String) [],remoteexception
    + FullyQualifiedErrorId : NativeCommandError
 
1 file,1183794 bytes (1157 KiB)

Extracting archive: hurt.log
Can not open the file as archive

Can't open as archive: 1
Files: 0
Size:       0
Compressed: 0


                2  (              %xU

怎么了?当我手动给出7zip路径时,将提取所有存档。 仅当从文件提供要存档的补丁程序时,才会发生此错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)