Unable to Pipe Multiple Files

I am trying to go through all the files under a folder ('C:\Users\thchen\Desktop\ReplaceTests') to look for a particular string pattern ('FindString') and replace it with another ('ReplaceString') using the following code:

It gets confusing using $_ and depending on where you are in the pipeline it could not be what you expect, so first thing is use $file in your first loop to ensure the correct context is used. Next, you were referencing $_ for Get-Content, which is an object, not a path, so updated to .FullName. Last, you are recursing through a directory structure, so you need to specify -File to only process files:

This gets you 99% of the way there. The only other problem is if you have sub directories in your path, you will get an access denied when you try to "Get-Content" on the directory path. This is because a directory is not a file and you can't get it's content. To resolve this you should tell Get-ChildItems to only return file objects, not directory objects, using the -File parameter.

***Note: These are all the same things that Rob did with his provided example, just keeping $_ instead of switching to another variable. I just wanted to show it was just the .FileName and -File adjustments he made that was the difference. Switching to another variable was not necessary, but it does make the code easier to read.***