Something broke overnight, the app wrote forty log files, and all you have is an error code like ERR-504 . You don't need PowerShell, an editor, or a log tool for the first pass. findstr ships with every Windows install since XP, works in a locked-down cmd.exe , and can tell you which files contain the code, which lines , and whether it's there at all in one command.
This post is the version I actually use: search a whole folder tree, get line numbers, list only file names, avoid the space-separated-words trap, and use the exit code in a batch script.
The one-liner
findstr /s /i /n /l /c:"ERR-504" C:\Logs\*.log
Enter fullscreen mode
Exit fullscreen mode
What each switch does:
/s searches the current folder and every subfolder .
/i ignores case, so err-504 and ERR-504 both match.
/n prints the line number in front of each hit.
/l treats the search text literally (no regex surprises).
/c:"..." searches for the exact string, spaces included.
Output looks like this, one hit per line, with…