Download Today File only

Advertisement

anon1m0us
Joined:
Posts:
1
Location:
New York

Download Today File only

I am using the script that is provided:
# Select the most recent file
$latest =
$directoryInfo.Files |
Where-Object { -Not $_.IsDirectory } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1


# Any file at all?
if ($latest -eq $Null)
{
Write-Host "No file found"
exit 1
}

# Download the selected file
$session.GetFiles(
[WinSCP.RemotePath]::EscapeFileMask($latest.FullName), $localPath).Check()

But when I change the code to only to Today's files, and not do the latest it fails.

$directoryInfo.Files |
Where-Object { -Not $_.IsDirectory } |
get /mydocuments/* -filemask=*>Today

It does not work. Any help?

Reply with quote

Advertisement

You can post new topics in this forum