Main idea here is to send an email when i new file or folder is created in some path.
for $body it should say new file detected: FILENAMEHERE
$path = "Z:\"
$limit=$(Get-Date).AddMinutes(-1)
$sendmail= $To="me@domain.com";$From= "administrator@domain.com";$Subject = "new file created";$Body= "New File Detected";$Message = New-Object System.Net.Mail.MailMessage $From, $To, $Subject, $Body;$smtpServer = "smtp.domain.com";$smtp
= new-object Net.Mail.SmtpClient($smtpServer);$smtp.EnableSsl = $false;$smtp.Credentials= New-Object System.net.NetworkCredential("administrator@domain.com","password");$smtp.Send($message);
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit} | Then {$sendmail}