vCenter Alarm Definition Migration

Alarms play a very important role in vCenter in order to keep the VMware admins aware of what’s going on with their environments. Even if you have vCOPS configured, I personally still like to have alarm definitions set up, specially in the event that the vCOPS vApp is shutdown, etc.

One of the use cases for alarm definition migration is the creation of a new vCenter, or even just wanting to have all vCenters configured with the same alarms. You can do all this manually, but If you have defined alarm definitions in the past, you already know this a very time consuming task and new versions of vCenter include more and more alarms as new releases are introduced. You can also have your own alarms, in which case, it make sense to have a method to copy such definition when needed.

VMware has a KB article with a script dating from 4.x version. I used this script, which works well, but it leaves out a couple of minor details that may be overlooked, specially with people with little to no experience with Power Shell and PowerCLI. In KB1032660 VMware has a script that can do this for you, all you have to do is edit the script and run it. However, the picture shows PowerShell ISE “run” button for the screen shot. In an “out of box” environment, this will fail. Why? Because this script requires PowerCLI cmdlets (connect-viserver, etc.) and those are not part of PowerShell ISE unless you import the snap-ins manually, which is totally feasible.

Error

To make the script work, you’ll have to either add the PSSnapins or run the script from PowerCLI. The easiest way is to just run the script from PowerCLI. Although this is self explanatory, I will show how to go about doing that.

Overview:

  • Download latest version of PowerCLI from VMware downloads that match your environment
  • Download the script from VMware’s site KB1032660
  • Open the script using PowerShell ISE, notepad, notepad++, or your editor of choice
  • Edit the variables for $vc1 and $vc2 and line 92 to (true), then save the script

variables

ifTrue

  • Open PowerCLI
  • Navigate to the location where you saved your script and run the script from there

navigate

  • You will get a few prompts, just hit Y [default]

At this point you should see all the vCenter alarms copied to your target vCenter server. As you add alerts to your source vCenter, you can use this script to keep all your vCenters in sync until VMware comes up with this tool.

Feature request!?!?