Configuring alarms on all VMware alarm definitions automatically using PowerShell

 

My example contains alarm actions to send an email, but you can configure this for SNMP or any other actions. You can copy and paste this into a “.ps1” file to create a PowerShell scripts.

# This command will remove any alarms actions that are configured currently.

Get-AlarmDefinition | Get-AlarmAction | Remove-AlarmAction -confirm:$false

 

#This command will add an alarm action to send an email. It automatically adds the trigger for status "Yellow" to "Red".

Get-AlarmDefinition | New-AlarmAction -Email -To '[email protected]'

 

#This command adds and additional trigger to send an email when the the status changes from "Yellow" to "Green"

Get-AlarmDefinition | Get-AlarmAction -ActionType "SendEmail" | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green"