Running vCenter 7.01 and I'm trying to disable the alarm "Virtual machine memory usage' for a few VMs that run 100% all the time (appliances). When I click on the VM and go to Configure, Alarm Definitions I'm able to disable one at a time. (Cool new feature in 7!!!) but I can't figure out how to script it for a few VMs. Can anyone help? May not be possible yet.
Here is an example of my script
get-vm <name*> | Get-AlarmDefinition -Name 'Virtual machine memory usage' | Set-AlarmDefinition -Enabled:$false
If I run this it disables the alarm at the vCenter level for all the VMs.
Unfortunately that feature is not yet covered by a PowerCLI cmdlet.
But you can always use the API DisableAlarm method directly.
$vmName = 'MyVM' $alarmName = 'Virtual machine memory usage' $vm = Get-VM -Name $vmName $alarm = Get-AlarmDefinition -Name $alarmName $alarmMgr = Get-View AlarmManager $alarmMgr.DisableAlarm($alarm.ExtensionData.MoRef,$vm.ExtensionData.MoRef)
To enable an alarm on a specific VM, you just call the EnableAlarm method.