3 Replies Latest reply on Nov 20, 2018 3:02 AM by LucD

    Ack Alarm PowerCli

    Bunty11 Enthusiast

      Getting error when runnig this code -- > Exception calling "AcknowledgeAlarm" with "2" argument(s): "The object has already been deleted or has not been completely created"

       

       

      Connect-VIServer -Server $xxx -Credential $cred | Out-Null;

      $alarmMgr = Get-View AlarmManager;

      $rootFolder = Get-Folder -Name Datacenters;

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

      $AllAlarms = $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}};

        • 1. Re: Ack Alarm PowerCli
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          You have Acknowleged at twice.

          Try like this

          Connect-VIServer -Server $xxx -Credential $cred | Out-Null

          $alarmMgr = Get-View AlarmManager

          $rootFolder = Get-Folder -Name Datacenters

          $rootFolder.ExtensionData.TriggeredAlarmState | Where {-not $_.Acknowledged} |

          ForEach-Object -Process {

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

          }

          $AllAlarms = $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}}

          $AllAlarms

           

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

            if the alarms are already acknowledged it gives error.

             

            Exception calling "AcknowledgeAlarm" with "2" argument(s): "The object has already been deleted or has not been completely created"

            • 3. Re: Ack Alarm PowerCli
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

              I changed the While-condition, the code above is updated.

              Please try again.

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz