title: Powershell - Find & Replace Dates
body: <p>I'm looking for a bit of assistance here. I currently have a Powershell script which adjusts the dates within a file. I'm looking to stop myself having to manually adjust these dates every time. What I need is to replace the date two days ago, with the date from yesterday.</p>
  
  <p>I believe that I'd have to use <code>(Get-Date).AddDays(-1)</code> and <code>(Get-Date).AddDays(-2)</code> but I'm not exactly sure how I'd script this in!</p>
  
  <p>What I currently have:</p>
  
  <pre><code>echo "Adjusting Import Dates"
  
  (Get-Content D:\Temp\Example.txt).replace('20180917', '20180918') | Set-Content  D:\Temp\Example.txt
  </code></pre>