Techop09
asked on
Filter Huge Text File Based on Search String through Powershell
Hi,
I have a HUGE text file (over 10 GB) that has an export of ACLs from over 600,000 folders. I'm looking to use Powershell to filter this huge file based on a search string, in this case, the search string would be a certain domain user. What I want Powershell to do is find the search string in the original file and output it every instance of it along with the immediate 10 lines above where it was found a new text file. I hope this makes sense. Thanks.
I have a HUGE text file (over 10 GB) that has an export of ACLs from over 600,000 folders. I'm looking to use Powershell to filter this huge file based on a search string, in this case, the search string would be a certain domain user. What I want Powershell to do is find the search string in the original file and output it every instance of it along with the immediate 10 lines above where it was found a new text file. I hope this makes sense. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd like to ask for partial credit, points split, if I could between me and Qlemo.
$FilePath = "D:\powershell\stuff\*.*"
select-string -pattern "Guido" -path $FilePath -context 10
I used it from http://www.computerperformance.co.uk/powershell/powershell_select_string.htm
Good luck!
DH