I have this code that works great if there is a new file in the last 23 hours. how can I adjust it that if there is no new files in the last 2 days it will send me an emailParam ( [string]$Path = "d:shared\ftpimport\failed", [string]$SMTPServer = "mail.optonline.net", [string]$From = "SFTPAlert@yahoo.com", [string]$To = "morris@yahoo.com", [string]$Subject = "New File Failed to upload" )$SMTPMessage = @{ To = $To From = $From Subject = "$Subject at $Path" Smtpserver = $SMTPServer}$File = Get-ChildItem $Path | Where { $_.LastWriteTime -ge [datetime]::Now.Addhours(-23) }If ($File){ $SMTPBody = "`nThe following files have recently been added/changed:`n`n" $File | ForEach { $SMTPBody += "$($_.FullName)`n" } Send-MailMessage @SMTPMessage -Body $SMTPBody
↧