Migrating Email Alarm Actions between vCenter 5.0 and 5.1
I needed to migrate some Email Alarm Actions between two vCenters; the target at version 5.1 being a replacement for an existing 5.0 vCenter. The first task was to identify which Alarm Definitions had been configured with an email alert. To do that I used the following PowerCLI command to export them to a CSV file:
Get-AlarmDefinition | Select Name,@{N="EmailAction";E={$\_ | Get-AlarmAction | Where {$\_.ActionType -eq "SendEmail"}}} | Export-Csv AlarmActions.csv -NoTypeInformation
I could then easily identify those which needed to be migrated across.
Before creating new Email Alarm Actions in the 5.1 vCenter I wanted to check that the alarms which had been configured with an Email Actions still existed in 5.1, since it’s reasonably likely to assume that there will be some changes in Alarm Definitions that exist between vCenter versions. After modifying my CSV to cut out those I didn’t need, I imported the data into PowerShell and ran a query to establish if any no longer matched:
$data = Import-CSV AlarmActions.csv Get-AlarmDefinition ($data | Select -ExpandProperty Name)
One didn’t exist anymore; one appeared similar, but significantly renamed; a couple of others appeared to have a minor name change.
The two minor name changes to me look unnecessary, inconsistent and frankly a bit sloppy. To the naked eye you might not even notice them, and you might even think what’s the big deal, but adding a full stop character at the end of an Alarm Definition when it was not there in the previous version and the majority of other definitions don’t have them is pretty poor.
vCenter 5.0 (no full stop)
vCenter 5.1 (full stop)
Anyway, I updated my data source to match the new names and created the new Email Actions on the Alarm Definitions that required them:
$data = Import-CSV AlarmActions.csv Get-AlarmDefinition ($data | Select -ExpandProperty Name) | New-AlarmAction -Email -To "[email protected]"