Link to home
Start Free TrialLog in
Avatar of Robert Perez-Corona
Robert Perez-CoronaFlag for United States of America

asked on

Powershell script to send email via Gmail if file is older than specified time

Hello,

I have a directory on a windows 2012 server where text files are dumped in order to be uploaded to a SQL server for ETL purposes; which generate a report to for a production site.

I need a powershell script ( or any script) to alert me via gmail (google apps) if the files in my directory are older than "X" amount time; 15 hours to be exact.

many thanks in advance

t
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Why not download and install the free version of PRTG for proper monitoring instead?
Avatar of Robert Perez-Corona

ASKER

Thanks for pointing out other solutions

With respect to prtg, I already have nagios and currently working on implementing GLPI.

Do you think I can achieve the same with nagios?

I'm any case, how would any of these net mon tools monitor the date/time stamp ?

I have a feeling this will require some tweaking
ASKER CERTIFIED SOLUTION
Avatar of x-men
x-men
Flag of Portugal image

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
Thanks x-men let me give the the script a shot
Exception calling "Send" with "4" argument(s): "The SMTP server requires a secure connection or the client was not auth
enticated. The server response was: 5.5.1 Authentication Required. Learn more at"
At C:\Users\myuser\Documents\email-alert.ps1:11 char:21
+     $SMTPClient.Send <<<< ($EmailFrom, $EmailTo, $Subject, $Body)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException




I replaced the variables inside the quotations with my own values (kept the quotes) yet I received the message above related to auth
It seams like you were unable to authenticate with Google. There is a security option on Google accounts to allow connections from legacy applications (it's just a name that Google gives to what ever's not from Google)... Will send you the complete walkthrough in about 12 hours.  (Got to get my beauty sleep...)
cheers x-men
SOLUTION
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
SOLUTION
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