A Small but Useful PowerShell Script

I always keep this little PowerShell script handy for when I need to search my source code for instances of a particular word or phrase. Most modern IDEs have this kind of functionality built in, but you never know when you’ll have to work with a language or tool that isn’t quite as robust.

$search_path = "c:\Your\Search\Path\"
$search_pattern = "YourSearchTerm"

clear

Get-ChildItem -recurse -include *.txt, *.cs $search_path | `
    Select-String -pattern $search_pattern | `
    Format-List -GroupBy Filename -Property LineNumber, Line
About Adam Platt

Adam Platt is a technologist with more than a decade of experience across the full stack. His passion for technology and penchant for rendering complex technical ideas into simple terms have made him an in-demand speaker. His resume includes BriForum, the PowerShell Summit, teaching engagements and more.

He is one of the 10 types of people who understand binary and he can solve a Rubik’s Cube.

About Adam Platt

Adam Platt is a technologist with more than a decade of experience across the full stack. His passion for technology and penchant for rendering complex technical ideas into simple terms have made him an in-demand speaker. His resume includes BriForum, the PowerShell Summit, teaching engagements and more.

He is one of the 10 types of people who understand binary and he can solve a Rubik’s Cube.