We recently noticed some hosts in our environment that show an alert triggered by ‘Status of other host hardware objects’. Upon further investigation it turned out that this was caused by the system event log (SEL) that is about to run out of space.
Now if you don’t mind not having a bit of history of your hardware-related events you can easily clear it and there’s even a function in vCenter that lets you do that. However it turns out that – at least in vCenter 6.7 U2 – the reset function doesn’t actually perform a reset but a refresh instead.

Using the code capture shows this behavior. And this clearly NOT what we intended.

Luckily the vSphere Web Services API documentation clearly shows that there’s a ClearSystemEventLog method. So what’s to stop us from writing a simple PowerCLI function? Well……. actually nothing.
function Clear-VMHostSEL { Param( [parameter(Mandatory=$true, ValueFromPipeline=$true)]$VMHosts ) process { foreach($VMHost in $VMHosts){ $VMhostView = Get-View $VMHost Write-Host "Clearing System Event Log Of: $VMHost" $VMhostHealthView = Get-View -Id $VMhostView.ConfigManager.HealthStatusSystem $VMhostHealthView.ClearSystemEventLog() } } }
Once you enter this function in a powershell session and log on to your vCenter you can pass a list of ESXi hosts to this function with Get-VMHost and it will clear the system event log. Just like this.
Get-VMhost -Name SomeHost | Clear-VMHostSEL
Enjoy!
3 Comments
Daniel Andryszak · July 5, 2022 at 5:27 pm
Nice function.
BTW – “Using the code capture shows this behavior. And this clearly NOT what we intended.”
What are you using to capture code?
Bryan van Eeden · July 9, 2022 at 8:41 am
Hi, the code capture functionality is a button that you can enable in the Development Center settings on the vCenter to allow you to capture code for anything you are doing in the UI. I hope this helps. For more information have a look at: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vcenterhost.doc/GUID-0E74A054-4E4C-45E7-B0F2-0320834C9DAB.html#:~:text=Code%20Capture%20gives%20you%20the,vCenter%20Server%20calls%20are%20recorded.
Ram · December 8, 2022 at 3:51 pm
In the function call why are we passing ‘-Name SomeHost’ ? By default, Get-VMhost return all the hosts, the same is piped to the function and the loop inside would take care of each hosts right?