Search Files Recursively with Get-ChildItem

PowerShell one-liner to locate files by name in all subfolders, tolerating access-denied paths.

WindowssearchFilespowershellLow risk
Run `Get-ChildItem -Path <dir> -Recurse -Filter "*.log" -ErrorAction SilentlyContinue` to find matching files in every subfolder.

01Command

Command
$ Get-ChildItem -Path "$env:USERPROFILE" -Recurse -Filter "*.txt" -ErrorAction SilentlyContinue

02What it does

-Recurse makes the search descend all subdirectories, while -Filter applies a fast, provider-level filename pattern that is quicker than -Include for a single pattern. -ErrorAction SilentlyContinue suppresses the access-denied noise that recursing system folders always produces. Because the output is FileInfo objects, you can immediately pipe to Sort-Object Length or Where-Object LastWriteTime to narrow results further.

03Risk

RiskLow risk

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions