LockDown32
asked on
Need program to monitor folders
I have a customer that wants to monitor a folder (or folders) on her server and be notified via email when a new file shows up. Since there is no office on the server this program needs to include smtp settings.
ASKER
Since there is no email client on the server how would powershell send the email?
You dont need an emailclient for that. Just a mailserver that accepts the email without auth:
sample:
This CODE checks for a new FILE and sends you an email with the file as attachemnt. Afterwards it MOVES the file in the second folder. Its only a sample.
sample:
# Checks for new files in $SearchPath. New Files will be mailed to $EmailTo and then moved to $MovePath
# Use with Taskscheduler to execute every 5 Minutes
$SearchPath = "C:\temp\file\folder1"
$MovePath = "C:\temp\file\folder2"
$EmailTo = "itsame@mydomain.com"
$EmailFrom = "TheServer@contoso.com"
$EmailSubject = "A new file is in the folder"
$EmailBody = "An new file has arrived"
$mailserver = "MyMailserver.mydomain.com"
$IncomingFiles = Get-ChildItem $SearchPath
ForEach($NewFile in $IncomingFiles)
{
If ($Newfile -ne $null) {
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -smtpserver $mailserver -Attachments ($NewFile).FullName
move-item -path $SearchPath"\"$NewFile -destination $MovePath
}
}
This CODE checks for a new FILE and sends you an email with the file as attachemnt. Afterwards it MOVES the file in the second folder. Its only a sample.
ASKER
I found that early on Danial and the functionality was a mess. It didn't "install" as a service or anything and you couldn't really tell if it was running or not. Then the SMTP settings didn't offer a place for complete authentication settings. Will try your link and see if it does anything different....
Have you seen How To Monitor a Windows Folder for New Files
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Lockdown32
You are Level 15 here. Sure you need our help?
https://www.raymond.cc/blog/3-portable-tools-monitor-files-folders-changes/
You are Level 15 here. Sure you need our help?
https://www.raymond.cc/blog/3-portable-tools-monitor-files-folders-changes/
ASKER
Directory Monitory really foot the bill. Low cost, custom email settings and it even worked as advertised!
Great, glad that helped.
»bp
»bp
If you need to monitor more, PRTG would be a good choice. If its only the one single folder, a powershell script which runs as task every 5 minutes or so would be enough. would that be suitable (single powershell script)?
regards
Thomas