However, I thought I might try to refresh my rusty PoweCLI knowledge. Therefore, I picked up the first article in search results which provided a good PS script for vCenter 5.0 and useful links for automation of the boring process of setting "Send Email" action for all Alarms. Definitely, there is still no descent explanation why VMware hasn't provided such configuration option.
While I was applying this script to my infrastructure I found out that number of Alarms differ from version to version. Here, in my company we have vCenter 5.0 Update 1a in production and vCenter 5.1 in test environment. Therefore, I have decided to adjust the script for both our versions.
So, here are the links to the scripts which might be useful for you.
- Set Email Notification script for vCenter 5.0
- Set Email Notification script for vCenter 5.0 Update 1a
- Set Email Notification script for vCenter 5.1
- Excel file with all Alarms categorized by vCenter version - god knows why you would need it :)
There are plenty opportunities to customize these scripts for more sophisticated actions, but for my scarce PoweCLI skills just an email is more than enough :)
If you find this post useful please share it with any of the buttons below.
Oh my, it changes with every update / version?! Painful. VMware should keep better tabs on their api
ReplyDeleteWhat das that error mean?:
ReplyDeleteGet-AlarmDefinition -Name “$actAlarm1" | Get-AlarmAction | New-AlarmActionTrigger <<<< -StartStatus 'Red' -EndStatus 'Yellow' -Repeat
+ CategoryInfo : NotSpecified: (:) [New-AlarmActionTrigger], InvalidArgument
+ FullyQualifiedErrorId : Client20_AlarmServiceImpl_NewAlarmActionTrigger_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Alarm.NewAlarmActionTrigger
To make this easier, you can get the alarm names dynamically and set them into an array then act on the array name. This also allows the script to account for any custom alarms:
ReplyDelete$alarms = Get-AlarmDefinition | Select -ExpandProperty "Name"
Get-AlarmDefinition -Name $alarms | Get-AlarmAction | Remove-AlarmAction -Confirm:$false
Get-AlarmDefinition -Name $alarms | New-AlarmAction -Email -To $MailTo
etc, etc.
Hope this helps anyone else out there looking to do this!