<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Otto Helweg - Management Matters : Alerts</title><link>http://blogs.technet.com/otto/archive/tags/Alerts/default.aspx</link><description>Tags: Alerts</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Automate E-Mail Alerts with Windows Vista</title><link>http://blogs.technet.com/otto/archive/2007/03/01/e-mail-alerts-with-windows-vista.aspx</link><pubDate>Thu, 01 Mar 2007 22:24:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:667250</guid><dc:creator>ottoh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/otto/comments/667250.aspx</comments><wfw:commentRss>http://blogs.technet.com/otto/commentrss.aspx?PostID=667250</wfw:commentRss><description>&lt;P&gt;The Windows&amp;nbsp;Task Scheduler as been completely re-written for Windows Vista&amp;nbsp;to be a very powerful automation tool. The Task Scheduler now has the ability to launch tasks from a wide variety of useful triggers rather than being limited to the standard time based trigger.&amp;nbsp;One of the most powerful triggers is the 'On an event' trigger and this example can easly be extended to leverage it for even more alerting options.&amp;nbsp;In addition, tasks can now&amp;nbsp;execute notifications (message box and e-mail)&amp;nbsp;where they were previously limited to the&amp;nbsp;standard command line action.&lt;/P&gt;
&lt;P&gt;This example sets up a simple e-mail alert using Task Scheduler and PowerShell which sends an e-mail every time somebody connects to (login, remote desktop, or unlocks) the local computer. This might be useful for auditing access to critical systems in a data center.&lt;/P&gt;
&lt;P&gt;Consider the 2 options for sending an e-mail alert from the new Task Scheduler:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667244/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;1 - E-Mail Action using PowerShell:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Since this PowerShell script uses the SmtpClient object in Windows, it has more flexibility when dealing with SMTP server authentication requirements. This example sends the alert e-mail through an SMTP server that does not require authentication.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;2- E-Mail directly through a Task Scheduler action:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Although the new Task Scheduler supports direct e-mail actions via SMTP, it is limited to fairly specific scenarios. It will only work if authentication is required by the SMTP server &lt;STRONG&gt;and&lt;/STRONG&gt; the credentials used for the SMTP authentication need to be the same credentials used to run the task. For these reasons, this example will focus on option #1.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Open 'Task Scheduler' and create a task to run whether the user is logged on or not&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667240/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Create 3 triggers ('At log on', 'On connection to user session', 'On workstation unlock'). Notice that an 'On event' trigger may be used instead to track a wide variety of state changes in a computer.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667243/original.aspx" border=0&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 3:&lt;/STRONG&gt; Create the action to run the PowerShell e-mail script&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667245/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 4:&lt;/STRONG&gt; Create the PowerShell script (for this example it's called 'ConnectionAlert.ps1')&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;$emailFrom = "computer@nospam.com"&lt;BR&gt;$emailTo = "somebody@nospam.com"&lt;BR&gt;$subject = "Connection Alert"&lt;BR&gt;$body = "Somebody has connected to the computer."&lt;BR&gt;$smtpServer = "somesmtpserver.nospam.com"&lt;BR&gt;$smtp = new-object Net.Mail.SmtpClient($smtpServer)&lt;BR&gt;$smtp.Send($emailFrom,$emailTo,$subject,$body)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 5:&lt;/STRONG&gt; Test the PowerShell Script&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;C:\&amp;gt; PowerShell ./ConnectionAlert.ps1&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 6:&lt;/STRONG&gt; Test the Task by running it directly from the Task Scheduler, then by locking and unlocking the computer.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For more information:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Windows Vista Task Scheduler: &lt;A href="http://msdn2.microsoft.com/en-us/library/aa383614.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa383614.aspx&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Get PowerShell bits and information: &lt;A class="" href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx" mce_href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=667250" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/otto/archive/tags/Alerts/default.aspx">Alerts</category><category domain="http://blogs.technet.com/otto/archive/tags/Automation/default.aspx">Automation</category><category domain="http://blogs.technet.com/otto/archive/tags/Vista/default.aspx">Vista</category><category domain="http://blogs.technet.com/otto/archive/tags/Task+Scheduler/default.aspx">Task Scheduler</category></item></channel></rss>