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"
}
Just change the 1st line to
$vmhost = Get-VMHost
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just change the 1st line to
$vmhost = Get-VMHost
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks! I tested it and it worked. To enable and disable.