Travis Quinnelly bio photo

Travis Quinnelly

vTechify is my home to talk about all things virtualization. Here I share things learned in lab and production environments both for my documentation and others to stumble upon for reference.

Twitter Google+ LinkedIn Instagram Github

I found the below snippets on VirtIRL.

This configures all vCenter alarms to send an email:

Get-AlarmDefinition | New-AlarmAction -Email -To ''

Now you can create an alarm trigger to send an email when the monitored item changes from green to yellow as well. The default alarm action automatically creates the alert for yellow to red (above example).

Get-AlarmDefinition | Get-AlarmAction -ActionType SendEmail | where-object {$_.To -like ''} | New-AlarmActionTrigger -StartStatus 'Green' -EndStatus 'Yellow'

To add other transitions (red to yellow, yellow to green) you can just change the -StartStatus and -EndStatus to the necessary values.

To see all Alarms configured to send to a certain email address along with triggers:

Get-AlarmDefinition | Get-AlarmAction -ActionType SendEmail | Where-Object {$_.To -like ''} | Select AlarmDefinition,To,Trigger

To remove all SendEmail AlarmActions for a particular email address:

Get-AlarmDefinition | Get-AlarmAction -ActionType SendEmail | where-object {$_.To -like ''} | Remove-AlarmAction