title: Powershell: Replace text on specific line in file
body: <p>I have some text files looking something like this:</p>
  
  <hr>
  
  <p>Text 05-09-18<br>
  Text 17-09-18<br>
  Text 17-09-18  </p>
  
  <p>Text 24-09-18<br>
  Text 17-10-18  </p>
  
  <hr>
  
  <p>On line 15 in the .txt files, I'm trying to change from 24-09-18 to 24-09-2018.<br>
  Changing only this and not the other ones.  </p>
  
  <ul>
  <li>The [15] overrides the .txt file with a empty one.  </li>
  <li>If [15] is not present then it changes all dates in the .txt file.</li>
  </ul>
  
  <p>Here's what I'm been doing so far:</p>
  
  <pre><code>$infolder = Get-ChildItem C:\folder\*.txt -rec
  foreach ($file in $infolder)
  {
  (Get-Content $file.PSPath) |
  Foreach-Object { $_[15] -replace '-18','-2018'} |
  Set-Content $file}
  </code></pre>