title: Loop through files in a directory using PowerShell
body: <p>How can I change the following code to look at all the .log files in the directory and not just the one file?</p>
  
  <p>I need to loop through all the files and delete all lines that do not contain "step4" or "step9". Currently this will create a new file, but I'm not sure how to use the <code>for each</code> loop here (newbie).</p>
  
  <p>The actual files are named like this: <strong>2013 09 03 00_01_29.log</strong>. I'd like the output files to either overwrite them, or to have the SAME name, appended with "out".</p>
  
  <pre><code>$In = "C:\Users\gerhardl\Documents\My Received Files\Test_In.log"
  $Out = "C:\Users\gerhardl\Documents\My Received Files\Test_Out.log"
  $Files = "C:\Users\gerhardl\Documents\My Received Files\"
  
  Get-Content $In | Where-Object {$_ -match 'step4' -or $_ -match 'step9'} | `
  Set-Content $Out
  </code></pre>