-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModify Host Alarm actions.ps1
More file actions
44 lines (33 loc) · 1.16 KB
/
Copy pathModify Host Alarm actions.ps1
File metadata and controls
44 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#Written by Jeremy Dixon
#Date Modified: 1-21-19 V 1.0
################################################################################
## Script will Disable or Enable host alarm actions on all host in a cluster. ##
################################################################################
#Vcenter we want to connect to.
$VC = "vctr01pi03lv.corp.nm.org"
#Disable or Enable?
$action = "Disable"
#Connect to VCenter
#Connect-VIServer -Server $VC -ErrorAction Stop
$alarmMgr = Get-View AlarmManager
#Disable or Enable?
$action = "Disable"
#Get all host for cluster
$esxi = get-vmhost -location Tier1-CTX-App01
#For each host in cluster, modify the alarm action.
foreach ($esx in $esxi) {
if($action -eq "Disable")
{
write-host "disabling alarm actions on $esx"
# To disable alarm actions
$alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$fase)
}
Else
{
write-host "Enabling alarm actions on $esx"
# To enable alarm actions
$alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$true)
}
}
#Disconnect from vcenter
#Disconnect-VIServer -Server $VC