mobot
asked on
Send email using a Scheduled Task thats attached to an Event ID using Windows Server 2008 R2 Standard?
I'm creating a Basic Task using the Wizard, and then attaching that task to the Scheduled Task. I want to receive an email when the event is logged. I'm not getting the email. Under the the History Tab I see it failed with this msg. IIS 7.5 is running, I don't see the smtp service running if that matters.
Would somebody clue me in on what I need to do to make this happen?
+ System
- Provider
[ Name] Microsoft-Windows-TaskSche duler
[ Guid] {DE7B24EA-73C8-4A09-985D-5 BDADCFA901 7}
EventID 202
Version 0
Level 2
Task 202
Opcode 102
Keywords 0x8000000000000000
- TimeCreated
[ SystemTime] 2010-08-20T19:45:05.048062 300Z
EventRecordID 14231
- Correlation
[ ActivityID] {3EF22033-2BA7-4A10-A450-3 82187D033B 7}
- Execution
[ ProcessID] 6016
[ ThreadID] 6384
Channel Microsoft-Windows-TaskSche duler/Oper ational
Computer name.mydomain.org
- Security
[ UserID] S-1-5-21-32063543-13479085 93-1251826 310-500
- EventData
TaskName \Event Viewer Tasks\System_Microsoft-Win dows-WAS_5 186
TaskInstanceId {3EF22033-2BA7-4A10-A450-3 82187D033B 7}
ActionName Sys Evt Log Info event id5186 ComputerName
ResultCode 2147746323
Would somebody clue me in on what I need to do to make this happen?
+ System
- Provider
[ Name] Microsoft-Windows-TaskSche
[ Guid] {DE7B24EA-73C8-4A09-985D-5
EventID 202
Version 0
Level 2
Task 202
Opcode 102
Keywords 0x8000000000000000
- TimeCreated
[ SystemTime] 2010-08-20T19:45:05.048062
EventRecordID 14231
- Correlation
[ ActivityID] {3EF22033-2BA7-4A10-A450-3
- Execution
[ ProcessID] 6016
[ ThreadID] 6384
Channel Microsoft-Windows-TaskSche
Computer name.mydomain.org
- Security
[ UserID] S-1-5-21-32063543-13479085
- EventData
TaskName \Event Viewer Tasks\System_Microsoft-Win
TaskInstanceId {3EF22033-2BA7-4A10-A450-3
ActionName Sys Evt Log Info event id5186 ComputerName
ResultCode 2147746323
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks, the batch file does solve the problem. I get an email when the event is triggered.
Hope this helps somebody else.
rem - 1 line powershell script, named sendemail.ps1
send-mailmessage -to "serveradmin@domain.org" -from "server@domain.org" -subject "Test Mail" -body "Check server" -smtpserver.domain.org
rem - 1 line batch file to run the script.
powershell.exe c:\myscripts\sendemail.ps1
From within Powershell for help.
get-help send-mailmessage -examples
Hope this helps somebody else.
rem - 1 line powershell script, named sendemail.ps1
send-mailmessage -to "serveradmin@domain.org" -from "server@domain.org" -subject "Test Mail" -body "Check server" -smtpserver.domain.org
rem - 1 line batch file to run the script.
powershell.exe c:\myscripts\sendemail.ps1
From within Powershell for help.
get-help send-mailmessage -examples
ASKER
I've just started digging into Powershell, and using the send-mailmessage cmdlet. I've got the script running from within Powershell, from the Run box, and from the DOS shell cmd line, and it works. Now I'm trying to make it work as a task from for a user defined Data Collector Set. The basic if the cpu spikes above this limit send me an email. Your idea of a batch file will probably work for that too.
On the Windows 2003 servers, I've got a little vb script that I run from a batch file, cscript sample.vbs that does this for us. I tried it on 2008 and it flakes out so I started down the Powershell road.
Thanks