VMware Cloud Community
naveenbaldwa1
Enthusiast
Enthusiast

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

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

0 Kudos
2 Replies
Alex_Romeo
Leadership
Leadership

LucD

ARomeo

Blog: https://www.aleadmin.it/
0 Kudos
LucD
Leadership
Leadership

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos