Need help improving code

Nov 22, 2011 at 6:32 PM

Hello,

I am fairly new to Powershell and i have written a script to do the following:  I have a txt file(strings.txt) with over 600 lines, the scripts reads each line and performs a search of that string against over 14,000 zip files which contain a txt file.  My problem is that my current script runs into memory problems and i am hoping someone here can help me improve the efficiency of my script. 

Below is my script, any help or ideas for improving this would be greatly appreciated, I am using and have imported the PSCX module.

 

Get-Content "C:\<path_to_search_values>\strings.txt" | `
 Foreach-object {Read-Archive -Path "C:\<path_to_zip_files>\*.zip" -Format Zip | `
     Where-Object { $_.Name -like "*.txt" } | `
        Expand-Archive -PassThru | select-string -pattern $_ |`
            Format-Table -GroupBy path}

Thank you