Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Powershell Script to get a latest file with a Specific dynamic name

So just add your constraint. Something like:
$latest =
    $directoryInfo.Files |
    Where-Object { -Not $_.IsDirectory } |
    Where-Object { $_.Name.Contains("1234") } |
    Sort-Object LastWriteTime -Descending |
    Select-Object -First 1

(assuming you are using this script: https://winscp.net/eng/docs/script_download_most_recent_file#powershell)
nashreddy369@gmail.com

Powershell Script to get a latest file with a Specific dynamic name

Hi,
i am new to this topic i saw how to download the most recent file powershell script but i have an additional requirement.
in addition to most recent criteria, i want to download a specific file name (eg: file_1234_shape.txt) with dynamic part which keeps on changing, the *1234* part in the example changes everyday but the rest remains same.
please provide a powershell script to download latest file with Specific Dynamic name.
i am currently using the powershellscript to download most recent file.