Skip to content

Instantly share code, notes, and snippets.

@hansgafriedzal
Created December 15, 2023 08:54
Show Gist options
  • Save hansgafriedzal/084e41dcc449ac659f4b0798a8a6bf6c to your computer and use it in GitHub Desktop.
Save hansgafriedzal/084e41dcc449ac659f4b0798a8a6bf6c to your computer and use it in GitHub Desktop.
cd ''
dir -File -Recurse | where Extension -eq .log | foreach {
Write-Progress $_.BaseName
$flag = $false
cat $_ | foreach {
$line = $_ | sls 'ERROR' -CaseSensitive
if ($line.count) {
Write-Host
$line.Line
$flag = $true
}
elseif ($flag) {
if ($_.Trim() -like 'at*') {
$_
}
elseif ($_.Trim() -notlike 'at*') {
$flag = $false
}
}
}
}
Write-Progress -Completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment