7 Replies Latest reply on Aug 21, 2018 9:23 AM by LucD

    Power Cli - Ack Alarm

    Bunty11 Enthusiast

      I want to Acknowledge all alarms in my vCenter using VMware PowerCLI.

       

      $Datacenter = Get-Datacenter | select ExtensionData

      $Datacenter.ExtensionData.TriggeredAlarmState.Acknowledged -like "True"

        • 1. Re: Power Cli - Ack Alarm
          LucD Guru
          Community WarriorsvExpertUser Moderators

          Try like this

           

          $alarmMgr = Get-View AlarmManager

           

          $rootFolder = Get-Folder -Name Datacenters

          $rootFolder.ExtensionData.TriggeredAlarmState |

          ForEach-Object -Process {

              $alarmMgr.AcknowledgeAlarm($_.Alarm,$_.Entity)

          }

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: Power Cli - Ack Alarm
            Bunty11 Enthusiast

            will this give me description of all alarms ?

             

            $Rootfolders.ExtensionData.TriggeredAlarmState | ForEach-Object -Process {$alarmMgr.Description($_.Alarm,$_.Entity)}

             

            How can i get the list of alamrns with name and and status like i see it in GUI.?

            • 3. Re: Power Cli - Ack Alarm
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

              Try like this

               

              $rootFolder = Get-Folder -Name Datacenters

              $rootFolder.ExtensionData.TriggeredAlarmState |

              Select @{N='Alarm';E={(Get-View -Id $_.Alarm -Property Info.Name).Info.Name}},

                  Time,OverallStatus

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              1 person found this helpful
              • 4. Re: Power Cli - Ack Alarm
                Bunty11 Enthusiast

                Check this

                 

                $rootFolder.ExtensionData.TriggeredAlarmState | Where {$_.Acknowledged -like "False"} | ForEach-Object -Process {$alarmMgr.AcknowledgeAlarm($_.Alarm,$_.Entity)}

                 

                This will acknowledge only those alarms which are not acknowledged by any users 

                • 5. Re: Power Cli - Ack Alarm
                  LucD Guru
                  Community WarriorsUser ModeratorsvExpert

                  Yes, and...?

                  The alarms listed under TriggeredAlarmState all have Acknowledged set to $false.
                  If the alarm is acknowledged, it will disappear from that list.

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 6. Re: Power Cli - Ack Alarm
                    Bunty11 Enthusiast

                    I am not understanding how u used -ID in Get-View.

                    I am trying to get object name on which alarm has came for each alarm, but i am unable to get it.

                    • 7. Re: Power Cli - Ack Alarm
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      The Entity property contains a pointer, a so-called MoRef.
                      With the Get-View you can retrieve the object from the pointer.

                       

                      $rootFolder = Get-Folder -Name Datacenters

                      $rootFolder.ExtensionData.TriggeredAlarmState |

                      Select @{N='Alarm';E={(Get-View -Id $_.Alarm -Property Info.Name).Info.Name}},

                          Time,OverallStatus,

                          @{N='Entity';E={(Get-View -Id $_.Entity -Property Name).Name}}

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful