Forward Alerts by E-mail

In some scenarios you want to forward an alert to a engineer direct from the Operations Manager console. In this post I will show you a example how that can be done with a task. The task will run a power shell script that picks up properties of the alert and forward it by e-mail. Start by copy the script, mailforward.ps1, to C:\scripts on the machine running the console. The create the console task,

  1. In the Operations Manager console, navigate to Authoring > Tasks and create a new task
  2. Create a Console Tasks/Alert command line. Select a destination management pack and click Next
  3. On the General Properties page, input a task name, for example “Forward by e-mail”
  4. On the Command Line page, input
    • Application: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
    • Parameters: C:\scripts\mailforward.ps1 ‘$Name$’ ‘$Description$’ ‘$Managed Object Name$’
    • Working directory: C:\
    • Check “Display output when this task is run”
  5. Click OK to save the task

Now, when you select an alert you can see your new task in the actions pane, and if you click it you can input a note and a recipient, in the task output your will see the complete e-mail that is sent.

Note that in this example it is only the e-mail alias that you need to input, not the complete e-mail address. If you need to input a complete e-mail address you will need to update the powershell script. You also need to update the script with your e-mail domain, from address and mail server. You can download the script here, mailforward. Place it in C:\scripts on each machine that is running the console, or on a shared disk. Make sure that your task is using the correct path to the script. Do not forget to allow your console workstation to send e-mail. with your mail server

Please note that this is provided “as is” with no warranties at all.

16 thoughts on “Forward Alerts by E-mail

  1. How can we add the resolution to the e-mail to help the end user ?

    Is it possible to the full path and source information to the e-mail

  2. In case Rob or anyone else come across this and are having problems passing $Logging Computer$, try using $NetbiosComputerName$, that worked for me.

  3. I try my work email and let it come a error code which 80072EE5 Amesbury error I how fix server “https:\\exchange. contoson.com

  4. Hi, it should work them same way with SCSM 2012. We could use ORchestrator for this now too, even if it is a extra tool it could bring some value in this scenario. I have a couple of blog posts showing how to invoke a runbook from a task in the Service Manager console.

  5. Figured it out, issue with PowerShell 3.0. Here is how to solve it…
    Replace line 13…
    {$x=$objTextBox.Text;$objForm.Close()}})
    …with…
    {$Script:x=$objTextBox.Text;$Script:u=$objTextBox2.Text;$objForm.Close()}})
    AND
    Replace line 21…
    $OKButton.Add_Click({$x=$objTextBox.Text;$u = $objTextBox2.Text; $objForm.Close()})
    …with…
    $OKButton.Add_Click({$Script:x=$objTextBox.Text;$Script:u=$objTextBox2.Text; $objForm.Close()})

    Thanks for the script!

    Nick

  6. Have you updated this script to work with SCOM 2012 SP1? After following the steps, the task reports as successful with nothing in the Output window and no email being sent. I have updated smtpServer and alias fields appropriately within the script.

  7. Hi Anders,

    Great script!! I have modified the script and the task to add extra detail to the email. In particular, I am passing the $Logging Computer$ parameter but it never passes any data across to the script. Instead it passes $LoggingComputer$.

    c:\scripts\mailForwardToHelpDesk.ps1 ‘$Name$’ ‘$Description$’ ‘$Managed Object Name$’ ‘$Owner$’ ‘$Logging Computer$’

    All others work. Do you have any idea why it does not work?

  8. Anders,

    Just came across your script and task now. Excellent stuff and it solved a requirement for an OpsMgr project I’ve been involved in.

    Works perfect – thanks!

    🙂

    Kevin

  9. Hi Anders,

    Could you please help me to set-up automatic alert notification. As of now, If alert occurred, we are manually using forward to option to send the alert to the mail. Instead of this, is it possbile automatically forward the alert to the mail and that too, it should send till status changed to closed or resolved.

    Thanks and regards,
    -Gopal

  10. Hi, when you set this up you see that some parameters are not there, you cant insert them as variable. But you could solve that with a external script instead, trigger by powershell every X minute.

  11. Actually on another look, what i am looking for is the Logging Computer. I have seen that the “source” Is sometimes “MSSQLSERVER” instead of the computer name.

  12. Hello,
    The script you have works well, but it does not give all the info namely i need the source computer name in there, is there somewhere i can find a list of the variables that i can pass through with this script?

Leave a Reply

Your email address will not be published. Required fields are marked *