What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use PowerShell’s Select-String cmdlet to find text in files. Search files in the current folder with a wildcard path, or pipe files from Get-ChildItem -Recurse to search nested folders. Patterns are regular expressions by default; add -SimpleMatch when you want literal text.
Search files in the current folder
Give Select-String a file path or wildcard and the text pattern to find. This searches every matching text file in the current directory and reports matching lines with file and line information.
As an Amazon Associate I earn from qualifying purchases.
Select-String -Path .*.txt -Pattern 'Get-'
For log files, change the wildcard and pattern:
Select-String -Path .*.log -Pattern 'error'
-Path accepts wildcards, but a directory by itself is not a file search path. Use a file pattern such as .*.txt or enumerate files with Get-ChildItem. Quote paths that contain spaces.
Free tools Windows power users keep installed
One-click scans. No signup required.
Search nested folders recursively
Use Get-ChildItem to enumerate files under a folder, then pipe those file objects to Select-String. The following searches all .txt files below the current directory, including subdirectories:
#1 Best Overall
- Book - powershell for sysadmins: workflow automation made easy
- Language: english
- Binding: paperback
Get-ChildItem -Path . -Filter *.txt -Recurse |
Select-String -Pattern 'Microsoft'
Replace . with the folder you want to search. Depending on your permissions, PowerShell may also display access-denied messages for folders it cannot read.
Choose literal text or a regular expression
-Pattern treats its value as a regular expression by default. That is useful for pattern matching, but characters such as . have special meaning in regular expressions. For an ordinary phrase or exact sequence of characters, use -SimpleMatch.
Select-String -Path .*.txt -Pattern 'Get-' -SimpleMatch
Combine literal matching with case-sensitive matching when capitalization must also be exact:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Select-String -Path .*.txt -Pattern 'A.B' -SimpleMatch -CaseSensitive
Without -CaseSensitive, matching ignores capitalization. Without -SimpleMatch, A.B is interpreted as a regex, where the period can match a character rather than only a period.
Rank #3
Show context or change the output
By default, Select-String returns MatchInfo objects and reports the first match on each matching line. These options adjust what you get back:
- Show nearby lines:
-Context 2,3displays two lines before and three after each match. - Return a match indication:
-Quietreturns$trueif a match is found and$nullif none is found, instead of MatchInfo details. - Stop after a file’s first match:
-Listreturns only the first matching instance per input file. - Find multiple matches on one line:
-AllMatchesreports every match on a line; it is ignored when-SimpleMatchis used.
For example, to inspect lines around a timeout in a log:
Rank #4
Select-String -Path .app.log -Pattern 'timeout' -Context 2,3
To check whether any text file contains a term without displaying matching lines:
Select-String -Path .*.txt -Pattern 'needle' -Quiet
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Handle paths and file encoding carefully
Use -LiteralPath instead of -Path when the path must be treated exactly as typed and wildcard characters in it should not be expanded. Use -Path for wildcard searches such as ..
eports*.txt
Best Value
Encoding behavior depends on the PowerShell version and file. Microsoft’s overview says BOM detection is used and BOM-less files are assumed to be UTF-8; the PowerShell 7.6 parameter reference lists utf8NoBOM as the default for -Encoding. If you know a file uses a different encoding, specify it explicitly with -Encoding rather than assuming every PowerShell release handles it identically.
Select-String is intended to search input strings and file contents. When piping other kinds of objects, their string representation may differ from what formatted output shows. If you need to search formatted output, Microsoft documents piping through Out-String or Out-String -Stream.
Quick Recap
Quick choice guide
| Goal | Use |
|---|---|
| Search matching files in the current folder | Select-String -Path .*.txt -Pattern 'text' |
| Search files in subfolders too | Get-ChildItem -Path . -Filter *.txt -Recurse | Select-String -Pattern 'text' |
| Match a literal phrase or punctuation | Add -SimpleMatch |
| Require exact capitalization | Add -CaseSensitive |
| See surrounding lines | Add -Context before,after |
| Check only whether a match exists | Add -Quiet |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




