Link

#Import-Module VMware.VimAutomation.Core
#如果使用 6.5.0 之前版本,需要先导入模块

Connect-VIServer -Server 192.168.1.1
#连接vCenter


$selectedlocation="Cluster1"
#此处可以设置 Datacenter 名称或者 Cluster 名称以限制范围


$VMHostlist = Get-VMHost -location $selectedlocation | Sort-Object

foreach ($VMHost in $VMHostlist){

    Write-host "Preparing $($VMHost.Name) for ESXCLI" -ForegroundColor Yellow

    $ESXCLI = Get-EsxCli -VMHost $VMHost

    
    Write-host "clearing IPMI logs on $($VMHost.Name)" -ForegroundColor Yellow
    $action = $ESXCLI.hardware.ipmi.sel.clear()
    # 清日志
    
    Write-host $action.Message -ForegroundColor Green
    # 返回日志
}