Thursday, August 13, 2009

sendmail for Windows

SkyHi @ Thursday, August 13, 2009
http://forums.theplanet.com/lofiversion/index.php/t47439.html

http://eyedmax.com/2007/08/06/sendmail-for-windows-freeware/

http://totaldevpro.com/blogs/johnwood/archive/2009/05/20/free-sendmail-utility-for-windows.aspx


Here's an example of how you might use it:

sendmail /s mymailserver.com /f "John Wood " /t "Bill Goats " /j "invoice 205123" /m mailbody.txt /h





@ECHO OFF



rem A Quick-N-Dirty script to get a System Status on a Windows 2000 Server

rem You can run this from the command line or run it a scheduled task, hourly or daily,

rem and email the results to yourself. This provides a nice I'm Alive heartbeat from

rem your server. Just don't email it to an account on the same machine.



rem By VICOS -- 2004-07-25



rem This requires some free utilities from:

rem [url]http://www.sysinternals.com/ntw2k/freeware/pstools.shtml[/url]

rem We only need psinfo, psloglist, and pslist and I recommend only uploading

rem these 3 programs to your server. Why ask for trouble?

rem "All of the utilities in the PsTools suite work on Windows NT, Windows 2000 and Windows XP."



rem To Install:

rem 1. Create a folder on your server to store the files.

rem 2. Download the pstools noted above and upload the 3 utilities we need.

rem 3. Edit this batch file to make desired changes. Change the email command line

rem at the bottom to suit you.

rem 4. Upload this batch file.

rem 5. Add a cron task to run this batch file hourly or daily or whatever.



rem NOTE: sysinternals.com JUST released an update to psloglist that adds a -h switch.

rem This allows you to view logs for the past hour. Before, u were limited to the past day.

rem You will have to check if your verion has the -h switch and adjust the psloglist lines

rem accordingly. The number of hours specified should match how often u plan to run the script.

rem i.e. if you run it every hour in cron, use -h 1. Every 4 hours -> -h 4. Every day-> -d 1.



rem get the system uptime. Good to know if your system has recently rebooted.

psinfo | findstr Uptime: > results.txt





rem EventLog Errors for the last day -> System Log

ECHO. >> results.txt

ECHO ==================================================================== >> results.txt

ECHO SYSTEM LOG -- ERRORS and WARNINGS >> results.txt

ECHO ==================================================================== >> results.txt



rem "-f ew" will list "E"rrors and "W"arnings

rem psloglist -f ew -d 1 system >> results.txt

psloglist -f ew -h 1 system >> results.txt







rem EventLog Errors for the last day -> Application Log

ECHO. >> results.txt

ECHO ==================================================================== >> results.txt

ECHO APPLICATION LOG -- ERRORS and WARNINGS >> results.txt

ECHO ==================================================================== >> results.txt



rem "-f ew" will list "E"rrors and "W"arnings

rem psloglist -f ew -d 1 application >> results.txt

psloglist -f ew -h 1 application >> results.txt





rem EventLog for the last day -> Security Log -- FAILED LOGINS

ECHO. >> results.txt

ECHO ==================================================================== >> results.txt

ECHO SECURITY LOG -- FAILED LOGINS >> results.txt

ECHO ==================================================================== >> results.txt



rem -i #,#,# specifies which EventIDs we want to see. U can specify up to 10 IDs.

rem psloglist -i 529 -d 1 security >> results.txt

psloglist -i 529 -h 1 security >> results.txt





rem EventLog for the last day -> Security Log -- FAILED LOGINS

ECHO. >> results.txt

ECHO ==================================================================== >> results.txt

ECHO SECURITY LOG -- SUCCESSFUL LOGINS >> results.txt

ECHO ==================================================================== >> results.txt



rem -i #,#,# specifies which EventIDs we want to see. U can specify up to 10 IDs.

rem *** -c will clear the event log

rem psloglist -i 528,540 -d 1 security | findstr "Time: User: Package: Workstation:" >> results.txt

psloglist -i 528,540 -h 1 security | findstr "Time: User: Package: Workstation:" >> results.txt







rem Process List

ECHO. >> results.txt

ECHO ==================================================================== >> results.txt

ECHO RUNNING PROCESSES: >> results.txt

ECHO ==================================================================== >> results.txt

ECHO. >> results.txt



REM First, print the list header

pslist | findstr "Elapsed Time" >> results.txt



ECHO. >> results.txt



REM Now, print a sorted list of processes

pslist | findstr .*:.*: |sort >> results.txt







ECHO ==================================================================== >> results.txt

ECHO !!! END-OF-REPORT !!! >> results.txt





rem Email the report file (results.txt) to some off-site account

rem I use free BLAT SMTP utility to send the file: [url]http://www.blat.net/[/url]



c:pathtoblat c:pathtoresults.txt -t [email]you@somewhere.net[/email] -s "Server System Check"