VMware Cloud Community
vmk2014
Expert
Expert

Can we extract vCenter warning and alerts from Power Cli ?

Hi Team,

Can we extract lists of warning & Alerts in Vcenter from Power Cli ?

E.g. 

pastedImage_0.png

pastedImage_1.png

thanks

vmk

Tags (1)
0 Kudos
5 Replies
sk84
Expert
Expert

Some time ago I wrote a script that exports all triggered alarms as a CSV file. It's not nice, but it works.

powercli/export-all-triggered-alarms.ps1 at master · sebkirsch/powercli · GitHub

--- Regards, Sebastian VCP6.5-DCV // VCP7-CMA // vSAN 2017 Specialist Please mark this answer as 'helpful' or 'correct' if you think your question has been answered correctly.
0 Kudos
LucD
Leadership
Leadership

If you are looking for a history of fired alarms, you can do

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-1) |

where{$_ -is [VMware.Vim.AlarmEvent]} |

Select CreatedTime, @{N='Alarm';E={$_.Alarm.Name}},

   @{N='Entity';E={$_.Entity.Name}},

  FullFormattedMessage

If you are looking for events of type warning or error, you can do

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-1) -Types Error,Warning |

Select CreatedTime, Severity,EventTypeId,ObjectName,UserName,

  FullFormattedMessage


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vmk2014
Expert
Expert

LucD,

It seems we need to increase timeout settings but VC having huge events it appears.

PS C:\script> .\warning.ps1

Get-VIEvent : 01/10/2019 1:06:43 PM     Get-VIEvent             The request channel timed out while waiting for a reply

after

00:09:59.9746240. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the

Binding. The time allotted to this operation may have been a portion of a longer timeout.

At C:\script\warning.ps1:1 char:1

+ Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(- ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VIEvent], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent

0 Kudos
vmk2014
Expert
Expert

Will check and revert back. Thank you.

0 Kudos
LucD
Leadership
Leadership

How many days back did you query?
What is the WebOperationTimeoutSeconds set to in your environment?

You might experiment by setting it to a higher value.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos