VMware Cloud Community
Gary_KH_Lui
Contributor
Contributor

How to use PowerCLI to make an acknowledge/clear alarms on VMs

Dear all scripting professionals,

I would like to write a simple PowerCLI script to make the acknowledge of the alarm on VMs and clear them. I found some Cmdlets which might be useful on my requirement but I don't know how to use it in correct way.

Here is the Cmdlet I found

  • Get-AlarmActionTrigger
  • Remove-AlarmActionTrigger

Please advise me by using PowerCLI method to reset the alarm. I have to handle over 300 VMs alarm.

Thanks in advanced. Smiley Happy

Tags (1)
Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

Have a look at  1.  Re: reset and clear alarms for vms


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

Reply
0 Kudos
RichardBrown
Contributor
Contributor

Is this still not the case in vSphere 6??

HA restart alerts riddling our vCenter after patching on windows 2013 servers, acknowledging the alerts doesn't really change anything and i really want to run a foreach vm script with a where statement to find alarm-51....

$vm = get-vm "MyVM"

$vm |?{ $_.extensiondata.triggeredalarmstate.alarm.value -eq "alarm-51"} | %{(Get-View AlarmManager).AcknowledgeAlarm($_.ExtensionData.TriggeredAlarmState.Alarm, $_.ExtensionData.MoRef)}

Reply
0 Kudos
LucD
Leadership
Leadership

I'm afraid not, and afaik it will not be in the public API methods in 6.5 either.


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

Reply
0 Kudos
hugop
Hot Shot
Hot Shot

Unfortunately, clearing alarms is still not possible... you can only acknowledge them since the API to clear is not available.

You can however workaround this issue by disabling the alarm and then re-enabling it, this will clear the alarm for all objects. vCenter will also clear the alarm for all objects for you when the alarm is disabled.

For example, clearing VM MAC Conflict:

Get-AlarmDefinition "VM MAC Conflict" | Set-AlarmDefinition -Enabled $false

then once done, re-enable:

Get-AlarmDefinition "VM MAC Conflict" | Set-AlarmDefinition -Enabled $true

Reply
0 Kudos
LucD
Leadership
Leadership

Note that this will clear the Alarm for all the entities for which it was fired, not just one.
Just so everyone is aware of that.


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

Reply
0 Kudos
JediMasterMero
Enthusiast
Enthusiast

this is introduced in vsphere 6.7,  where a method part of the Alarmmanager can clear all the alarms based on their status (

vim.alarm.AlarmFilterSpec)

Reply
0 Kudos
elrichpo
Contributor
Contributor

thanks HugoP that was good solution to kill a bunch of alarms on VMs from a restore of a failed vCenter

-RichPo

Reply
0 Kudos