VMware Cloud Community
Bunty11
Hot Shot
Hot Shot
Jump to solution

Power Cli - Ack Alarm

I want to Acknowledge all alarms in my vCenter using VMware PowerCLI.

$Datacenter = Get-Datacenter | select ExtensionData

$Datacenter.ExtensionData.TriggeredAlarmState.Acknowledged -like "True"

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$alarmMgr = Get-View AlarmManager

$rootFolder = Get-Folder -Name Datacenters

$rootFolder.ExtensionData.TriggeredAlarmState |

ForEach-Object -Process {

    $alarmMgr.AcknowledgeAlarm($_.Alarm,$_.Entity)

}


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

View solution in original post

7 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$alarmMgr = Get-View AlarmManager

$rootFolder = Get-Folder -Name Datacenters

$rootFolder.ExtensionData.TriggeredAlarmState |

ForEach-Object -Process {

    $alarmMgr.AcknowledgeAlarm($_.Alarm,$_.Entity)

}


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

Bunty11
Hot Shot
Hot Shot
Jump to solution

will this give me description of all alarms ?

$Rootfolders.ExtensionData.TriggeredAlarmState | ForEach-Object -Process {$alarmMgr.Description($_.Alarm,$_.Entity)}

How can i get the list of alamrns with name and and status like i see it in GUI.?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

$rootFolder = Get-Folder -Name Datacenters

$rootFolder.ExtensionData.TriggeredAlarmState |

Select @{N='Alarm';E={(Get-View -Id $_.Alarm -Property Info.Name).Info.Name}},

    Time,OverallStatus


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

Bunty11
Hot Shot
Hot Shot
Jump to solution

Check this

$rootFolder.ExtensionData.TriggeredAlarmState | Where {$_.Acknowledged -like "False"} | ForEach-Object -Process {$alarmMgr.AcknowledgeAlarm($_.Alarm,$_.Entity)}

This will acknowledge only those alarms which are not acknowledged by any users 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, and...?

The alarms listed under TriggeredAlarmState all have Acknowledged set to $false.
If the alarm is acknowledged, it will disappear from that list.


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

Reply
0 Kudos
Bunty11
Hot Shot
Hot Shot
Jump to solution

I am not understanding how u used -ID in Get-View.

I am trying to get object name on which alarm has came for each alarm, but i am unable to get it.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Entity property contains a pointer, a so-called MoRef.
With the Get-View you can retrieve the object from the pointer.

$rootFolder = Get-Folder -Name Datacenters

$rootFolder.ExtensionData.TriggeredAlarmState |

Select @{N='Alarm';E={(Get-View -Id $_.Alarm -Property Info.Name).Info.Name}},

    Time,OverallStatus,

    @{N='Entity';E={(Get-View -Id $_.Entity -Property Name).Name}}


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