VMware Cloud Community
ar264285
Contributor
Contributor

How quick can I get the entire affected List of Virtual machines OR rebooted - Once HA Triggered

Once HA Event happens on 5.x series, How quick can I get the entire affected List of Virtual machines OR rebooted ?

Any script or CMD from VCLI to find the Event on Cluster. Let me know the CMD Details.

0 Kudos
2 Replies
Borja_Mari
Virtuoso
Virtuoso

Hello,

to get that list of virtual machines, you can use some excellent stuff from LucD (with at least powershell 2.0 and vmware powercli):

First, you need the Get-VIEventPlus function developed by LucD:

http://www.lucd.info/2013/03/31/get-the-vmotionsvmotion-history/

Then, use this script taken from here:

$entity = Get-Folder Datacenters

$start = (Get-Date).AddMonths(-3)

$Recurse = $false

$eventTypes = "com.vmware.vc.ha.VmRestartedByHAEvent"

Get-VIEventPlus -Entity $entity -Start $start -EventType $eventTypes |

Select CreatedTime,@{N="VM";E={$_.Vm.Name}},@{N="ESX";E={$_.Host.Name}}

Best regards,

Pablo

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob
0 Kudos
Borja_Mari
Virtuoso
Virtuoso

Hello again,

this script (taken from here😞

$Date = Get-Date

$HAVMrestartold =5

Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending

list the virtual machines restarted by HA in the last 5 days ($HAVMrestartold).

Maybe this is more easy to use than the LucD's script Smiley Happy

Obviously, you need powercli and powershell to run this script (and don't remember to use the Connect-VIServer cmdlet before, to be able to connect to the vCenter server)

Best regards,

Pablo

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob
0 Kudos