I'm trying to find lines starting from one of many patterns in many files (log parsing).
Is there any better solution than:
Get-ChildItem -Filter *DBLog.txt | ForEach-Object {
$name = $_.Name
Get-Content -Path $_.FullName |
Select-String -Pattern '^Msg*' |
Select-Object @{Name='File Name'; Expression={$name}}, LineNumber, Line
} |
Out-GridView
The above script unfortunately searches only for one pattern, and using Where-Object
I don't have the line number in which the pattern was found.