Last Updated: May 19, 2019
· 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.

2 Responses
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
6 months ago ·

I am very happy to read this. Appreciate your sharing

3 months ago ·