In vSphere Client on a VM host in the Alarms tab there is a view of Triggered Alarms.

How can I get those alarms using PowerCLI?

3 Answers 3


To find all vmhosts with alarm status = "red", I expanded on this.

# Find all hosts with triggered alarms in "Red" state
$esx_all = Get-VMHost | Get-View
foreach ($esx in $esx_all){
    foreach($triggered in $esx.TriggeredAlarmState){
        If ($triggered.OverallStatus -like "red" ){
            $lineitem={} | Select Name, AlarmInfo
            $alarmDef = Get-View -Id $triggered.Alarm
            $lineitem.Name = $esx.Name
            $lineitem.AlarmInfo = $alarmDef.Info.Name
$Report |Sort Name | export-csv "c:\temp\ESX-Host-Red-Alarms.csv" -notypeinformation -useculture
Invoke-item "c:\temp\ESX-Host-Red-Alarms.csv"
  • You can format your code as it is formatted now (I've done it for you) by indenting with 4 spaces. Nov 13, 2013 at 2:23

this is what i use.

$esx = Get-VMHost $vmhost | Get-View
foreach($triggered in $esx.TriggeredAlarmState){
  $alarmDef = Get-View -Id $triggered.Alarm
  Write-Host $alarmDef.Info.Name
  • I had tried that but it never returned anything at all, while the "Triggered Alarms" view in vSPhere Client showed my triggered alarm. (I created a triggered alarm based on a VM being used more than 1% CPU over 30 seconds as a test alarm.) Jul 4, 2013 at 8:25
  • You may need to look at the vm view in that case. I am not sure if vm alarms are included in the vmhost view.
    – johnshen64
    Jul 5, 2013 at 14:04

To expand a bit on johnshen64's PowerCLI answer, I found Luc Dekens' post on communities.vmware.com to be very helpful:

foreach($dc in (Get-Datacenter | where {$_.ExtensionData.triggeredAlarmState})){
    $dc.ExtensionData.triggeredAlarmState |
    Select @{N="Entity";E={Get-View $_.Entity | Select -ExpandProperty Name}},
        @{N="Alarm";E={Get-View $_.Alarm | Select -ExpandProperty Info | Select -ExpandProperty Name}},Time,OverallStatus,

... and I ended up using a variation of that:

foreach ($toplevel in    @(Get-VDSwitch    | Where-Object { $_.ExtensionData.TriggeredAlarmState.count -gt 0 }) +
                         @(Get-Datacenter  | Where-Object { $_.ExtensionData.TriggeredAlarmState.count -gt 0 })) {
    foreach ($alarm in $toplevel.ExtensionData.TriggeredAlarmState) {
        $localt = [System.TimeZoneInfo]::ConvertTime($alarm.time, [System.TimeZoneInfo]::Local)
        $entity = Get-View $alarm.Entity
        $alarmview = Get-View $alarm.Alarm
        Write-Output ("Alarm: At top-level entity $($toplevel.Name), $($entity.Name) went " +
                        "$($alarm.OverallStatus) at $($localt) for $($alarmview.Info.Name)")

The idea is to loop through each top-level entity that the alarms could roll up to. I discovered through trial and error that Get-VDSwitch and Get-Datacenter covered what I needed. The other tricky part is to realize that the Entity and Alarm objects inside the alarm are references to the actual objects, so to get details about the actual item, you have to dereference it with Get-View.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.