Share via


How to implement search text in zip-archive using powershell

Question

Monday, December 5, 2011 5:04 PM

$search = Read-Host "String:"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.System.Environment") | out-null
$MachineName = [System.Environment]::MachineName
$path = "\\$MachineName\PROJECTS"
Set-Location $path
$dirs = Get-ChildItem
foreach ($dir in $dirs)
{
    
    Get-ChildItem -Path $path\$dir\Traces -Recurse -Include *.trace  | where-object {(gc $_) | Select-String $search}

}

how to now organize the search in the zip file

how to organize such a search in the archive, unpack it and then manually search for it is not possible because zip archive a huge amount (> 1000)

All replies (1)

Friday, December 23, 2011 5:06 PM

From your original post, it sounds like you want to find a text string inside a lot of text files inside of a ZIP package.

I don't know that there's a method of doing what you're asking. I think you would need to follow a process similar to this:

  1. Extract the contents of the ZIP package to a temporary location
  2. Perform the search
  3. Clean up the temporary extraction path

Hope this helps.

If this post was helpful, please click the little "Vote as Helpful" button :)

Trevor Sullivan
Trevor Sullivan's Tech Room
Twitter Profile