If you have .Net 4.5 installed you can use System.IO.Compression.FileSystem library to create a function which will open and traverse contents of your zip files
$searchTerms = @( "test","bingo","false","one two","england")
function openZip($zipFile){
try{
[Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" ) | Out-Null;
$zipContens = [System.IO.Compression.ZipFile]::OpenRead($zipFile);
$zipContens.Entries | % {
foreach($searchTerm in $searchTerms){
if ($_.Name -imatch $searchTerm){
Write-Output ($_.Name + "," + $_.FullName + "," + $_.CompressedLength + "," + $_.LastWriteTime + "," + $_.Length);
}
}
}
}
catch{
Write-Output ("There was an error:" + $_.Exception.Message);
}
}
You can then run something like this to obtain filename,full path within zip, compressed size etc.
Get-ChildItem -Path -$filePath *.zip -Recurse -ErrorAction SilentlyContinue | % {
openZip $_.FullName >> c:patho
eport.csv
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…