Automation

 View Only
Expand all | Collapse all

Modify Cluster Alert Disable Script for All Hosts in a vCenter

  • 1.  Modify Cluster Alert Disable Script for All Hosts in a vCenter

    Posted Feb 09, 2023 01:02 PM

    How can I modify this script below to enable or disable all alerts on on hosts in a vCenter instead of just single clusters?

    #Disable Alarms for All Hosts in Cluster

    $vmhost=get-cluster Clustername|get-vmhost
    Write-Host "`nAlarm Disabled for $vmhost"
    $alarmaction= Get-View AlarmManager
    foreach($esx in Get-VMHost -Name $vmhost.Name) {
    $alarmMgr.EnableAlarmActions($cluster.Extensiondata.MoRef,$false)
    Write-Host "`nAlarm Disabled for $esx"
    }


    #Enable Alarms for all Hosts in Cluster

    $vmhost=get-cluster Clustername|get-vmhost
    Write-Host "`nAlarm Enabled for $vmhost"
    $alarmaction= Get-View AlarmManager
    foreach($esx in Get-VMHost -Name $vmhost.Name) {
    $alarmMgr.EnableAlarmActions($cluster.Extensiondata.MoRef,$true)
    Write-Host "`nAlarm Enabled for $esx"
    }



  • 2.  RE: Modify Cluster Alert Disable Script for All Hosts in a vCenter
    Best Answer

    Posted Feb 09, 2023 01:09 PM

    Just change the 1st line to



  • 3.  RE: Modify Cluster Alert Disable Script for All Hosts in a vCenter

    Posted Feb 09, 2023 01:29 PM

    Thanks!  I tested it and it worked.  To enable and disable.