detox1978
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
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
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 the scripts....
I dont have smtpsend, do you know of a free commercial version?
Thanks
phil
I dont have smtpsend, do you know of a free commercial version?
Thanks
phil
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
smtpsend is not free for comercial use, is there a way to use exchanges' smpt?
I don't know.
ASKER
will post in the exchange section...
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.
ASKER
cheers, will look into
ASKER
thanks for the links and tips....
looked into and it seemed like a lot of work.
ended up buy Selm from GFI.
P
looked into and it seemed like a lot of work.
ended up buy Selm from GFI.
P
@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