Link to home
Start Free TrialLog in
Avatar of LockDown32
LockDown32Flag for United States of America

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.
Avatar of Thomas U
Thomas U
Flag of Switzerland image

Hi Lockdown32

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
Avatar of LockDown32

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:

# 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
		}
	}

Open in new window


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.
Avatar of Daniel Pineault
Daniel Pineault

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....
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Lockdown32
You are Level 15 here. Sure you need our help?

https://www.raymond.cc/blog/3-portable-tools-monitor-files-folders-changes/
Directory Monitory really foot the bill. Low cost, custom email settings and it even worked as advertised!
Great, glad that helped.


»bp