Last Updated: May 29, 2024
· whatishedoing

PowerShell Recursive Search

A little snippet I use often: finding specific text within a large folder hierarchy, omitting files I know aren't of use:

Get-ChildItem *.cs -Exclude *Test*.cs -Recurse | Select-String "something" -SimpleMatch

Appending | Group Path | Select Name will further filter that list to just the files that contain the required text.

1 Response
Add your response

Loving the ability to further augment search with pipes. Here, I can (roughly) find all unique icons in alphabetical order:

Get-ChildItem -Include ('*.html', '*.ts') -Recurse | Select-String "['""]+.*(icon-[a-zA-Z\-]+)" | % { $_.Matches.Groups[1].Value } | Select-Object -Unique | Sort-Object
over 1 year ago ·