Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Using Get-Content to parse log files, need to get the parent file in the list.

$
0
0

I am trying to use Get-Content in the same manner as grep in Linux. I have it working to display the correct data from the files, but I would like it to also include the log file that the data was found in.

 

function Verify(){

Get-Content C:\Users\user\Documents\ScrubbedFiles\*\*.*_scrubbed.txt | Select-String -Pattern ('<data to find>') -AllMatches | Out-File C:\Users\user\Documents\Verification\verified.txt -Width 300

}

Verify

How do I get this to also grab the "parent" log file name that it was found in? It works if I use Select-String by itself, but I can't use that with multiple data fields, <data to find> is a list of about 15 patterns.
Thanks
 

Viewing all articles
Browse latest Browse all 6937

Trending Articles