Last Updated: February 25, 2016
· dwimbley
0 yhcbize9t0qclvhzpip4ibumimt85vhzofn4in4dpyvksyc4ratws9ufdc3x6j3ngi8m2a6ujuze

Powershell Recursive Search

I've often found myself having to search for files containing certain content and windows explorer just doesn't do it for me. This method utilizes powershell to recrusively search within the directory to return the full file path and line number of any files matching your search

Option one searches within the current directory you are in within powershell.

C:\users\david> ls -recurse | Select-String "google" | Select Path, LineNumber | Format-List

Option two lets you specify some other directory then the one you are in.

C:\users\david> ls c:\temp\searchfolder -recurse | Select-String "google" | Select Path, LineNumber | Format-List

ls: unix command which is aliased to Get-ChildItem in powershell (works like dir in cmd)

Select-String: Above examples are same as Select-String -pattern "google". Select-String returns a ManagementInfo Object (which is the Select Path, LineNumber) more here

Say Thanks