Hi Team,
We have more than 100 ESXi host in our environment and we need to find out when was the last time ESXi Host re-booted and no of times re-booted in last 1 month.Please help me to get the power cli script. Any help will be much appreciated.Thanks
Thanks
vmware tech
Ok, so the ESXi nodes were hard booted (as if you pushed the power button).
That is probably why the task for a scheduled reboot doesn't turn up.
Do you see the ESXi nodes with the following script ?
It shows the events where the connection to a host was lost.
$start = (Get-Date).AddDays(-7)
Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |
where{$_ -is [VMware.Vim.HostConnectionLostEvent]} |
Select CreatedTime,@{N='VMHost';E={$_.Host.Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$start = (Get-Date).AddMonths(-1)
Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |
Where-Object {$_ -is [VMware.Vim.ExtendedEvent] -and $_.EventTypeId -match '^com.vmware.vcIntegrity.RebootHostComplete'} |
Group-Object -Property {$_.Host.Name} |
Select @{N='ESXi';E={$_.Name}},
@{N='NumberOfReboot';E={$_.group.Count}},
@{N='Last Reboot';E={$_.Group | Sort-Object -Property CreatedTime -Descending |
Select -First 1 -ExpandProperty CreatedTime}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this variation
$start = (Get-Date).AddMonths(-1)
Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |
Where-Object {$_ -is [VMware.Vim.TaskEvent] -and $_.Info.Name -eq 'RebootHost_Task'} |
Group-Object -Property {$_.Host.Name} |
Select @{N='ESXi';E={$_.Name}},
@{N='NumberOfReboot';E={$_.group.Count}},
@{N='Last Reboot';E={$_.Group | Sort-Object -Property CreatedTime -Descending |
Select -First 1 -ExpandProperty CreatedTime}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
No luck still no output. PFA. Thanks
vmware tech
Do you see any entries under Task and Events when an ESXi host is rebooted ?
What does the Event and/or Task say ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
There was Storage issues during the weekend and all the Host (6) in a cluster, we re-booted forcibly from DRAC but i don't find in VC task and events. Any clue ?
Thanks
VMware tech
Ok, so the ESXi nodes were hard booted (as if you pushed the power button).
That is probably why the task for a scheduled reboot doesn't turn up.
Do you see the ESXi nodes with the following script ?
It shows the events where the connection to a host was lost.
$start = (Get-Date).AddDays(-7)
Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |
where{$_ -is [VMware.Vim.HostConnectionLostEvent]} |
Select CreatedTime,@{N='VMHost';E={$_.Host.Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I can see the script
CreatedTime VMHost
----------- ------
3/9/2015 5:50:01 PM VM1.48.ka.corp..com
3/9/2015 4:43:01 PM VM21.ka.corp..com
3/9/2015 3:52:00 PM VM3.ka.corp.com
Thanks
vmware tech
LuCD,
Does this mean these Host are forcibly re-booted ?
Thanks
VMware Tech