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,
- In the Operations Manager console, navigate to Authoring > Tasks and create a new task
- Create a Console Tasks/Alert command line. Select a destination management pack and click Next
- On the General Properties page, input a task name, for example “Forward by e-mail”
- 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”
- 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.
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.
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?
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
In case Rob or anyone else come across this and are having problems passing $Logging Computer$, try using $NetbiosComputerName$, that worked for me.
I try my work email and let it come a error code which 80072EE5 Amesbury error I how fix server “https:\\exchange. contoson.com
Thanks for sharing!
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.
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
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.
Hi, take a look at http://blogs.technet.com/b/kevinholman/archive/2007/12/12/adding-custom-information-to-alert-descriptions-and-notifications.aspx to see parameters to use.
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?
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
Hi, take a look at http://technet.microsoft.com/en-us/library/dd440889.aspx it will show you how to setup notification
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
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.
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.
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?
[…] VÃce zde: http://contoso.se/blog/?p=2608 […]