santoshmotwani
asked on
Powershell script to notify only new files
Hi Experts,
I have a production server executing files continuously . Sometimes i get files which are not in proper format hence they are not processed and they stay in there forever. I would like to have a script that will run every 5 mins on a specific folder to to check for newer files . I would like to have only new files as these files contains reason for failures. I would like file name to be sent via email.
This question is a followup of https://www.experts-exchange.com/questions/26895555/Powershell-script-to-notify-files-older-than-10-mins.html
I have a production server executing files continuously . Sometimes i get files which are not in proper format hence they are not processed and they stay in there forever. I would like to have a script that will run every 5 mins on a specific folder to to check for newer files . I would like to have only new files as these files contains reason for failures. I would like file name to be sent via email.
This question is a followup of https://www.experts-exchange.com/questions/26895555/Powershell-script-to-notify-files-older-than-10-mins.html
ASKER
in this script i only want to email new files ... does not matter if they stay there for months.
this folder actually contain logs ... as soon as something stops working a new text file is generated in this folder . I want whenever that file is generated it should be sent via email.
Thnx for help
this folder actually contain logs ... as soon as something stops working a new text file is generated in this folder . I want whenever that file is generated it should be sent via email.
Thnx for help
How often will you be scheduling the script to run?
regards
Prashanth
regards
Prashanth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for your help.
Thats exactly what i wanted
Thats exactly what i wanted
ASKER
@rwskas
If i add another email address , it does not send attachments.....
Can you please help
If i add another email address , it does not send attachments.....
Can you please help
ASKER
Can i please make a change, that it should only send email if there is a new file.
Can you post what you have changed? It should work that only a new file is emailed.
To add additional email addresses you should be doing:
$emailto = "someemail@domain.com, anotheremail@domain.com"
To add additional email addresses you should be doing:
$emailto = "someemail@domain.com, anotheremail@domain.com"
ASKER
@rwskas :
The script is working fine , it works fine for additional email as well.
But what i want is not to send blank emails, at this moment it is sending blank emails because of no new files. I want it to send a email only when a new file is created.
Thanks for your help
The script is working fine , it works fine for additional email as well.
But what i want is not to send blank emails, at this moment it is sending blank emails because of no new files. I want it to send a email only when a new file is created.
Thanks for your help
Modified piece attached should take care of that - sorry I overlooked it.
If ($NewFiles) {
Foreach ($NewFile in $NewFiles) {
$FileName = $NewFile.FullName
Email $NewFile
Add-Content $LogFile $FileName
}
}
ASKER
Thnx mate !!!!
regards
Prashanth