Home » System Center Operations Manager 2007 » Forward Alerts by E-mail

Contoso.se

Welcome to contoso.se! My name is Anders Bengtsson and this is my blog about Azure infrastructure and system management. I am a senior engineer in the FastTrack for Azure team, part of Azure Engineering, at Microsoft.  Contoso.se has two main purposes, first as a platform to share information with the community and the second as a notebook for myself.

Everything you read here is my own personal opinion and any code is provided "AS-IS" with no warranties.

Anders Bengtsson

MVP
MVP awarded 2007,2008,2009,2010

My Books
Service Manager Unleashed
Service Manager Unleashed
Orchestrator Unleashed
Orchestrator 2012 Unleashed
OMS
Inside the Microsoft Operations Management Suite

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.


18 Comments

  1. Hi,
    Thanks for reading my blog!

    $Managed Object Name$ is a parameter you send to the PS script when Operations Manager trigger the task. That should contain information about the object, for example, the server name. Maybe the name of the parameter has changed in newer version of SCOM PS.

  2. Hello,
    I realize this article was originally posted more than 7 1/2 years ago. But, I have almost the same question as SteveH had.

    In line one of the script I see param set and in the end of the script is where the email message is populated.
    param($title,$description,$object)

    $title and $description pass information about the alert, but the $object is blank.
    It doesn’t really do me any good to send an alert Title and Description if it doesn’t include where it came from. Server rebooted and the log was restarted is not very useful unless I know which server we’re talking about.

    Has use of $object changed with newer versions of SCOM or PowerShell? Is there another $unknown that will provide this information in the email?

    I’m using SCOM version 7.3.113261.0
    How can I provide the object creating the alert in the email?

  3. 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

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

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

  6. 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.

  7. 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

  8. 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.

  9. 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?

  10. 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

  11. 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

  12. 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.

  13. 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.

  14. 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 comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.