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