I am trying to automate snapshots on VM's and would like to disable the alerts on a single VM.
I found the documentation on how to do it manually: Enable and Disable Alarm Actions: https://docs.vmware.com/en/VMware-vSphere/6.0/com.vmware.vsphere.hostclient.doc/GUID-85A83C37-BE5B-4....
How can this be done via PowerCli?
Hi
You should be able to use EnableAlarmActions to set the alarm state. Below is a previous post on setting host alarms
Solved: PowerCLI: Enable / Disable Alarm Actions on Hosts ... - VMware Technology Network VMTN
to disabled on VMs you should just need to update the get-cluster to get-vm
$alarmMgr = Get-View AlarmManager
$vm = Get-VM -Name VMName
$alarmMgr.EnableAlarmActions($vm.Extensiondata.MoRef,$false)
To re-enabled just set to $true
Besides the defaults
System.Anonymous
System.Read
System.View
the account will need
Alarm.ToggleEnableOnEntity
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi
You should be able to use EnableAlarmActions to set the alarm state. Below is a previous post on setting host alarms
Solved: PowerCLI: Enable / Disable Alarm Actions on Hosts ... - VMware Technology Network VMTN
to disabled on VMs you should just need to update the get-cluster to get-vm
$alarmMgr = Get-View AlarmManager
$vm = Get-VM -Name VMName
$alarmMgr.EnableAlarmActions($vm.Extensiondata.MoRef,$false)
To re-enabled just set to $true
Ran into one more issue with the service account that I am using.
Exception calling "EnableAlarmActions" with "2" argument(s): "Permission to perform this operation was denied."
At line:1 char:1
+ $alarmMgr.EnableAlarmActions($vm.Extensiondata.MoRef,$false)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
What permissions are needed to execute this? It works when I log in as an Administrator but would like to give as little access to the service account as possible.
Besides the defaults
System.Anonymous
System.Read
System.View
the account will need
Alarm.ToggleEnableOnEntity
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference