title: Powershell to replace text in multiple files stored in many folders
body: <p>I want to replace a text in multiple files and folders. The folder name changes, but the filename is always config.xml.</p>
  
  <pre><code>$fileName = Get-ChildItem "C:\config\app*\config.xml" -Recurse
  (Get-Content $fileName) -replace 'this', 'that' | Set-Content $fileName
  </code></pre>
  
  <p>When I run the above script it works, but it writes the whole text in config.xml about 20 times. What's wrong?</p>