Using WinSCP from PowerShell to retrieve files modified within the last hour
<p>I'm using a PowerShell script to retrieve a file from a remote directory. I only want to retrieve a file if it was modified within the last hour. I was able to get the most recent file using the following code:</p>

<pre><code>$directoryInfo = $session.ListDirectory($remotePath) 

$latest = 
    $directoryInfo.Files | 
    Where-Object { -Not $_.IsDirectory } | 
    Sort-Object LastWriteTime -Descending | 
    Select-Object -First 1 
</code></pre>

<p>I believe that I need to add another condition to the <code>Where-Object</code> clause, but I don't know the proper format. For example, </p>

<pre><code>    Where-Object { -Not $_.IsDirectory and &lt;created/modified within the last hour&gt; } 
</code></pre>

<p>How do I do this? Is there a better/simpler way? </p>