title: ForEach-Object to look in subfolders
body: <p>I Have this powershell script “copFiles.ps1” that looks in a txt file &quot;Filestocopy.txt&quot; for a list  and copies them to a destination</p>
  <pre><code>$source = &quot;C:\Data\Filestocopy.txt&quot;
  $destination = &quot;C:\Data\Models&quot;
  Get-Content $source | ForEach-Object {copy-item $_ $destination}
  </code></pre>
  <p>It’ll only copy the files if they’re in the same folder as the .ps1 file and it ignores subfolders, how can I get it to look in subfolders of the folder that its in, I gather I need to use the -recurse option but don’t know how to rewrite it so it works.
  The .ps1 file is fired by a bat file.
  Many thanks</p>