title: Powershell select most recent file containing a specific string
body: <p>I have written a code in <code>powershell</code> that selects the most recent file in a directory.</p>
  
  <pre><code>$first = Get-ChildItem -Path $dir | Sort-Object CreationTime -Descending | Select-Object -First 1
  $first.name
  </code></pre>
  
  <p>However, I need to select the most recent file containing a specific string in the name. How can I adapt my code in order to do this?</p>