Hi all,
I am trying to get all files from a folder that are 24 hours old or less.
Its currently pulling all files in the folder, from months ago, but i only need files from the previous 24 hours only
Can anyone help with this.
$oneday = (get-date).addHours(24)
#write-host ($onehour.tostring('MM/dd/yyyy HH:mm:ss')) -fore yellow
$body = dir "\\server1\backups" -filter *.tar.gz –recurse | where{$_.creationtime -lt $onehour} | select FullName, CreationTime | ConvertTo-Html | Out-String
#$onehour
Send-MailMessage -SmtpServer "mailbox.domain.local" -From "nidge@nidge.com" -To "nidge@nidge.com" -Subject "test" -Body $body –BodyAsHtml
↧
Searching for files less than 1 day old
↧