Searching multiple files in PowerShell

Today I needed to check several scripts to see which ones used (the same) global field (don’t ask). I was doing this at work and Powershell proved to be surprisingly adept at doing this. All I needed was:

Get-ChildItem "Scripts_Folder" -recurse | Select-String -pattern "Field_Name" | group path | select name

… where Scripts_Folder is the folder containg the scripts and Field_Name is the field I was searching for.

Powershell returned a simple list of all of the files containing the field. I can see me needing to use this again, which is why I’m making a note of it here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s