Re: remove files older than days
Thank you prikryl for the code. I will definitely use it.
$directoryInfo = $session.ListDirectory($remotePath)
$limit = (Get-Date).AddDays(-15)
$oldFiles =
$directoryInfo.Files |
Where-Object { $_.LastWriteTime -lt $limit }
foreach ($oldFileInfo in $oldFiles)
{
$session.RemoveFiles($session.EscapeFileMask($remotePath + "/" + $oldFileInfo.Name)).Check()
}