Checking Alarm status of ESXi hosts in a cluster with PowerCLI

In a time of increased demand in web services, its our duty as Sys Admins to ensure that everything is running smoothly. Before doing any advanced optimization, the first step is ensuring that the environment is running with the correct configurations in place. To this end I dug through to the deepest bits of PowerCLI in the internet and made quite a big script that checks all settings and outputs a report. I will be breaking apart that script piece by piece and make a bit of a series for the benefit of the scripting community so that you won’t have dig as deep as I did 🙂

As the first part of the Configuration Health check series, let’s take a look at how we can check whether vCenter alarms are enabled on a ESXi host. Not only that lets see how we can get a report of which ESXi hosts have alarms disabled on each cluster. (So that you can go ahead and enable them like a good Admin 😉 )


First up we will check how we can check the alarm status of a single ESXi host. Its this same line that we will be expanding to get a report in a cluster. As is any PowerCLI/Powershell information hunt, it is digging up where this information is encapsulated in is the challenge

Get-VMHost <host_name> | $_.extensiondata.AlarmActionsEnabled

Here the One-Liner will return a $True or $False value where $True means Alarms are enabled and $False means that Alarms are disabled.

You can use the following one-liner to get a list of VMs with alarms disabled in the entire vCenter (with cluster name) and export as CSV

Get-VMHost | Where-Object {$_.extensiondata.AlarmActionsEnabled -eq $false} | Select @{N='Host';E={$_.Name}},@{N='Cluster';E={Get-Cluster -VMHost $_.Name}} | Export-Csv 'hosts_with_alarms_disabled.csv' 

Let’s see how we can expand this to obtain a comprehensive report on all clusters of your vCenter

Comprehensive Cluster report

$host_alarm_report = @()
$clusters = Get-Cluster

ForEach($cluster in $clusters){
    $details = @()
    $alrm_status = $cluster | Get-VMHost | Where-Object {$_.extensiondata.AlarmActionsEnabled -eq $false} | Select Name

    if($null -ne $alrm_status){
        $alrm_status = $alrm_status.Name -join ","
        Write-Host "$cluster Following hosts do not have Alarms Enabled $alrm_status "


        $alrm_status = "Alarms Enabled on all hosts"
        Write-Host "$cluster $alarm_action_status"

    $details = @{
		Cluster = $
		Alarms_disabled_hosts = $alrm_status


	$host_alarm_report += New-Object PSObject -Property $details | Select Cluster,Alarms_disabled_hosts


$host_alarm_report | Export-Csv "vcenter_host_alarm_report.csv"

The above script will give a csv report of all hosts in all clusters whose alarms are disabled. Hosts will be in one row separated by a comma (this is where the -join “,” part came in and will be categorized by Cluster which is why I believe its a more meaningful and comprehensive report even though its a larger script.

And that is it!

It makes me feel validated if you share, comment if you found this useful (no pressure 😉 ). Social media links are below!

And as always, Happy scripting!