title: How do I find the newest file in a directory using a PowerShell script?
body: <p>If, for example, I have a directory which contains the following files:</p>
  
  <pre><code>Test-20120626-1023.txt
  Test-20120626-0710.txt
  Test-20120626-2202.txt
  Test-20120626-1915.txt
  Test-20120626-1142.txt
  </code></pre>
  
  <p>As you can see, each file name contains the time of creation which is in a sortable format.</p>
  
  <p>How do I find the name of the latest file name (in this case <code>Test-20120626-2202.txt</code>) and store it in variable?</p>
  
  <p><em>Note: The directory path is also stored in a variable if it makes any difference.</em></p>