Hi @Mike R ,
maybe this helps to get it started (not tested by myself):
$smtphost = "mailserver.demo.local"
$to = "Administrator@demo.local"
$from = "Helpdesk@demo.local"
function Send-Mail {
param($From, $To, $Subject, $Body)
$smtp = New-Object system.net.mail.smtpClient($smtphost)
$mail = New-Object System.Net.Mail.MailMessage
$mail.from = $From
$mail.to.add($To)
$mail.subject = $Subject
$mail.body = $Body
$mail.isbodyhtml = $true
$smtp.send($mail)
}
$Subject = "New file found"
$Body = "New file found .... some more text"
$fileObj = Get-Item -Path C:\Public$\certconfig.txt
# Last Modified Date
if (($fileObj.LastWriteTime) -lt (Get-Date).AddHours(-24)) { Write-Output "Old file" }
else {
Write-Output "New file"
Send-Mail $from $to $subject $body
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten