title: PowerShell get-child item and get-content a few folders deep
body: <p>My script below only works for 1 folder using the "$_" before prior to the location of the file:</p>
  
  <pre><code>get-childitem E:\WebSystems\Configs\ | Foreach-Object {get-content E:\WebSystems\Configs\$_\Web.config} | foreach-object {$_ -replace "Web1", "Web2"} | set-content E:\WebSystems\Configs\$_\Web.config}
  </code></pre>
  
  <p>How about two folders deep? ex: E:\WebSystems\Configs\Folder1\Folder2\Web.config</p>
  
  <p>The following script doesn't work.</p>
  
  <pre><code>get-childitem E:\WebSystems\Configs\ | Foreach-Object {get-content E:\WebSystems\Configs\$_\$_\Web.config} | foreach-object {$_ -replace "Web1", "Web2"} | set-content E:\WebSystems\Configs\$_\$_\Web.config}
  </code></pre>