Setting vCenter Alarms with PowerCLI
vCenter as of version 5.0 defines 54 default alarms that can be configured for notification. What vCenter does not provide however is a way to automatically configure all those alarms to be sent to a single email address without having to manually go into each alarm. The below PowerShell script however will take care of that. After configuring the vCenter server connection information and changing the email address, this script will setup emails that are triggered by any change in alarm state. This is a one time email per state change, however you could use the –repeat option to set repeat emails for certain states if desired.
Note that in the Code you will not see anything to set the Yellow—>Red state. I could not find this documented anywhere but by default it appears this will be set. Including it in the code would result in errors.
http://www.seancrookston.com/set_alarms.ps1
I also managed to find someone who has written a much smaller set of code that will look for all existing alarms and set email notifications as well as another individual with a similar script for setting alarms.Check out these two posting for more details.
If you would like to know more about the various PowerCLI commands for alarms be sure to check out this VMware posting:
http://blogs.vmware.com/vipowershell/2010/12/managing-vsphere-alarms-with-powercli.html
February 13, 2012
Sean Crookston
Tags: 

Excellent! In addition to emails, you may want to configure actions based on alarms. Like e-mail, configuring these over and over again can get cumbersome. Good stuff!
I touched on kicking off actions with alarms here:
http://professionalvmware.com/2010/01/vsphere-host-died-abandon-ship-vsphere-vcenter-alarms-actions/
And scripts with alarms here:
http://professionalvmware.com/2010/09/protecting-your-virtual-machines-from-that-guy/
Which prompted Luc to write something similar:
http://www.lucd.info/2010/01/26/alarms-codys-abandon-ship/
-Cody
http://professionalvmware.com
Author of “Automating vSphere with vCenter Orchestrator”
http://amzn.to/zm7D75
Pingback: Open Tabs–Week ending 2/17/2012
Pingback: Webnetin - Great VMware VCP 5 Resources Page