2 Replies Latest reply on Feb 21, 2020 3:45 AM by LucD

    Get all triggered alarms of multiple vCenter (5.5,6.5,6.7)

    naveenbaldwa1 Novice

      Hello!!  I'm hoping someone can assist me with a PowerCLI script that can pull the subject info into a csv file.

       

       

       

       

       

       

       

       

      Thanks

       

       

      Naveen Kumar

        • 2. Re: Get all triggered alarms of multiple vCenter (5.5,6.5,6.7)
          LucD Guru
          Community WarriorsvExpertUser Moderators

          You could do something like this, provided you are connected to all the vCenters.

           

          $global:DefaultVIServers |

          ForEach-Object -Process {

              $vc = $_

              $si = Get-View ServiceInstance -Server $vc

              $alarmMgr = Get-View -Id $si.Content.AlarmManager -Server $vc


              Get-Inventory -Server $vc | ForEach-Object {

                  $alarmMgr.GetAlarmState($_.ExtensionData.MoRef) |

                  Where-Object { [VMware.Vim.ManagedEntityStatus]::yellow, [VMware.Vim.ManagedEntityStatus]::red -contains $_.OverallStatus } |

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

                  OverallStatus,

                  Time,

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

                  @{N = 'vCenter'; E = { $vc.Name } }

              }

          } |

          Export-Csv -Path .\alarm-report.csv -NoTypeInformation -UseCulture

           

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