Tuesday, January 27, 2009

PowerShell Script for Find In Files

A co-worker gave me this Windows PowerShell script that I used to find files that contained a certain value...because the Windows Search Companion stinks!

gci -include *.txt *.* |? { $n = $_.FullName; $t = $false; gc $_ |% {$t = $t -or $_.Contains("stringtofind")}; if($t) {$n} }

Seems to do the trick!

Thanks Jason Turnage!!! :)

No comments: