VMware Cloud Community
CaptPete3
Contributor
Contributor
Jump to solution

Modify Cluster Alert Disable Script for All Hosts in a vCenter

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"
}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Just change the 1st line to

$vmhost = Get-VMHost


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Just change the 1st line to

$vmhost = Get-VMHost


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

0 Kudos
CaptPete3
Contributor
Contributor
Jump to solution

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

0 Kudos