Look for and replace string in all files in a folder

by May 11, 2012

I have a raft of scripts that may reference a specific table.  As we're renaming the table I would like to have a powershell script that checks all scripts and updates them accordingly.

This works great for an individual file:

(Get-Content C:ScriptsTest.txt) | 
Foreach-Object {$_ -replace "*", "@"} | 
Set-Content C:ScriptsTest.txt

And I've modified it into a recursive loop:

$files=get-childitem $path -include *.txt -recurse

foreach ($i in $files){
(Get-Content  $i) |
Foreach-Object {$_ -replace "*", "@"} |
Set-Content  $i}

The next step is to output a list of all files that were affected. This bit has me really stumped.  It should ideally output to csv but even just the screen would be fine.  Could anyone help? 

Thanks in advance,