VMware Cloud Community
nealda
Contributor
Contributor

AcknowledgeAlarm Error, VM "has already been deleted"

I'm working on a script to acknowledge alarms but I'm running into an error. My production environment is vCenter Appliance 6.7 Update 3l.

I've converted all the variables to literals and run the commands from the PS command line to help me isolate the problem. Can anyone see the root cause of the error below given the two commands I've run?

PS H:\> (Get-VM -Name **redacted**).ExtensionData.TriggeredAlarmState.Key
alarm-7.vm-76683

PS H:\> (Get-View AlarmManager).AcknowledgeAlarm('Alarm-alarm-7', 'VirtualMachine-vm-76683')
Exception calling "AcknowledgeAlarm" with "2" argument(s): "The object 'vim.VirtualMachine:vm-76683' has already been deleted
or has not been completely created"
At line:1 char:1
+ (Get-View AlarmManager).AcknowledgeAlarm('Alarm-alarm-7', 'VirtualMac ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException

0 Kudos
1 Reply
LucD
Leadership
Leadership

I'm not sure the TriggeredAlarmState is updated.
In the API Reference it also states for triggeredAlarmState "In releases after vSphere API 5.0, vSphere Servers might not generate property collector update notifications for this property."

I would use the GetAlarm method on the AlarmManager service to get the state of Alarms for a VM.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos