Dell OpenManage Email Alerts (PS)

If you read our previous article Dell OpenManage Email Alerts (Bash), then you may be wondering how to send emails when OpenManage is installed on a Windows Server. When older versions of Dell OpenManage did not natively support e-mails we wrote a Powershell script in order to accomplish the task. In recent years the newer versions of Dell OpenManage do now support email alerts, however we have found our trusty old Powershell script is much easier to configure then using the in built alerts. Below is the Powershell script:

########################################################################################
#
# Filename: OpenManageAlert.ps1
# Created:  2014/03/29 by Matthew Marable
# Modified: 2017/05/05 by Marc Campos
#
# OpenManage Email Alert Script
#
########################################################################################
param ([switch]$configure)

$Server = gc env:computername

$body=$args[0]

if ($configure -eq $true) {
	` & "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=powersupply execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Power Supply Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=powersupplywarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Power Supply Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=tempwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Temperature Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=tempfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Temperature Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=fanwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Fan Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=fanfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Fan Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=voltwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Voltage Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=voltfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Voltage Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=intrusion execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Chassis Intrusion Detected'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=redundegrad execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Redundancy Degraded'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=redunlost execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Redundancy Lost"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=memprefail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Memory Pre-Fail'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=memfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Memory Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=processorwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Processor Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=processorfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Processor Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=watchdogasr execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Automatic System Recovery'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=batterywarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Battery Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=batteryfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Battery Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=systempowerwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Power Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=systempowerfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Power Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=systempeakpower execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Power'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagesyswarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Storage Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagesysfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Storage Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagectrlwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Storage Controller Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagectrlfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Storage Controller Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=pdiskwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Physical Disk Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=pdiskfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Physical Disk Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=vdiskwarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Virtual Disk Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=vdiskfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'Virtual Disk Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=enclosurewarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Enclosure Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=enclosurefail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'System Enclosure Failure'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagectrlbatterywarn execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'RAID Battery Warning'"
	& "C:\Program Files\Dell\SysMgt\oma\bin\omconfig.exe" system alertaction event=storagectrlbatteryfail execappath="powershell D:\Admin\Scripts\OpenManageAlert.ps1 'RAID Battery'" `
}
else {
	# Send email with alert
	$SmtpServer = "[your-smtp-server]"
	$SmtpServerPort = "587"

	$From = "[your-from-address]"
	$To = "[your-to-address]"

	$Message = New-Object System.Net.Mail.MailMessage( $From , $To )
	$Message.Subject = "$Server - OMSA Hardware Alert"
	$Message.IsBodyHtml = $false
	$Message.Body = "$body"

	$SMTPClient = New-Object System.Net.Mail.SmtpClient( $SmtpServer , $SmtpServerPort )
	$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("[your-from-address-username]", "[your-from-address-password]");
	$SMTPClient.Send( $Message )
}

In order to use the script above, first ensure it has been edited to reflect your environment. Once the script has been edited, simply fire up powershell and run the following command in order to apply the alert actions. Once the alert actions have been applied you should be able to test the script by pulling one of the power cords in a redundant setup.

D:\Admin\Scripts\OpenManageAlert.ps1 --configure
Did you find this article useful? Why not share it with your friends?

Leave a Reply

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.