Post a reply

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)


Topic review


how to delete fives older than x amount of days

The below Powershell script connects to my SFTP sever and deletes all my files under the path /test/my_file/.

Is there a way where I can say only delete files that is five days old under the path /test/my_file/

Add-Type -Path " WinSCPnet.dll"

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = ""
UserName = "username"
Password = "password"
SshHostKeyFingerprint = "ssh-rsa 1234 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

$sessionOptions.AddRawSettings("ProxyMethod", "0")
$sessionOptions.AddRawSettings("ProxyHost", "")
$sessionOptions.AddRawSettings("ProxyPort", "8080")

$session = New-Object WinSCP.Session


# Remove files
thank you in advance.