Automation

 View Only
  • 1.  Enable and Disable Alarm Actions on a Single VM

    Posted Jun 04, 2021 07:23 PM

    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-4A35-804F-901063CECFAB.html.

    How can this be done via PowerCli?



  • 2.  RE: Enable and Disable Alarm Actions on a Single VM
    Best Answer

    Posted Jun 05, 2021 09:17 PM

    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



  • 3.  RE: Enable and Disable Alarm Actions on a Single VM

    Posted Jun 07, 2021 02:34 PM

    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.



  • 4.  RE: Enable and Disable Alarm Actions on a Single VM
    Best Answer

    Posted Jun 07, 2021 02:44 PM

    Besides the defaults

    System.Anonymous
    System.Read
    System.View

    the account will need

    Alarm.ToggleEnableOnEntity