session.EnumerateRemoteFiles - only enumerate files older than x minutes

Advertisement

jw24
Guest

session.EnumerateRemoteFiles - only enumerate files older than x minutes

I am writing a PowerShell script to check whether files have been successfully processed from a SFTP site.

As part of this script I have the following:
$files = @($session.EnumerateRemoteFiles(
            "/pathToFolder", "*.txt", [WinSCP.EnumerationOptions]::None))
Is there a way to amend this so that it only enumerates files that have a created time of older than 10 minutes ago.

Reply with quote

Advertisement

jw24
Guest

solved

Solved by using the below
$files = @($session.EnumerateRemoteFiles(
            "/pathToFolder", "*.txt", [WinSCP.EnumerationOptions]::None)|
         Where-Object { $_.LastWriteTime -lt (Get-Date).AddMinutes(-10)})

Reply with quote

Advertisement

You can post new topics in this forum