Searching File Content

This bit… searches recursively the directory ‘c:\Samples’ all the files that end with ‘*.cs’.

It then pipes the results to the ‘where-object’ cmdlet, wich filters all files that contain the expression ‘*PropertyDescriptor*’.

After that, it selects the column FullName an redirects the output to the file ‘c:\result.txt’.

The magic part
gci -Path c:\Samples -Recurse -filter *.cs | Where-Object{(gc $_.FullName) -like “*PropertyDescriptor*”} | Select FullName > c:\result.txt

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 )

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


Follow

Get every new post delivered to your Inbox.