Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Batch Script to Email Event Log Warnings / Alerts

I want to create a batch script that will email me (via our exchange smtp) when a warning or error is logged in event viewer.

I found this post https://www.experts-exchange.com/questions/21399340/Send-Alert-when-Event-is-Logged-in-Windows-Server-2000.html ; which has this script.

____________________________________________________________________________________________
@echo off
setlocal ENABLEDELAYEDEXPANSION

dumpel -s \\servername -l system -d 1 -m Eventlog -e 6008|find "6008">alert.log
if not errorlevel 1 smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log
____________________________________________________________________________________________

is there a way i can modify this script to do what i want?

Thanks
Phil
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

You could schedule this task to run daily:

@echo off

if exist "ALERT.LOG" del "ALERT.LOG" >NUL

REM ** Change server as needed
for /f "delims=" %%a in ('dumpel -s \\server -l system -d 1') do call :PROCESS "%%a"

REM ** Change email info as needed
if exist "ALERT.LOG" smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log

goto :EOF

:PROCESS

for /f "tokens=4" %%a in ('echo %~1') do if /i "%%a" LEQ 2 call :DUMPIT %1

goto :EOF

:DUMPIT

echo %~1>>ALERT.LOG

Good Luck,
Steve
ASKER CERTIFIED SOLUTION
Avatar of CowboyJeeper
CowboyJeeper
Flag of United States of America 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
Avatar of detox1978

ASKER

thanks for the scripts....

I dont have smtpsend, do you know of a free commercial version?


Thanks
phil
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
smtpsend is not free for comercial use, is there a way to use exchanges' smpt?
I don't know.
will post in the exchange section...
Avatar of neteducation
neteducation

The Microsoft Exchange Resource Kit contains a program, SENDMAIL.EXE, which is a 32-bit command line  utility to send mail messages and file attachments. This program is also available in the Microsoft Mail Resource Kit.

cheers, will look into
thanks for the links and tips....

looked into and it seemed like a lot of work.

ended up buy Selm from GFI.


P