Friday, October 18, 2013

ESXi 5 syslog failed? Here how to restart it PowerCLI style

When any change is made the the syslog daemon on the ESXi Host a reboot or restart of the syslog daemon is required to get thing back on track. There is a couple ways you can restart the daemon but typically most people do it via CLI through SSH by issuing the command below:
esxcli system syslog reload

While there is nothing wrong with restarting the daemon this way, its quite annoying if you need to do this to a large number of ESXi Hosts. A much easier and fun way is to do it via PowerCLI using the Datacenter or Cluster variable.

Enjoy!
foreach ($esxhost in (Get-Datacenter -Name $Datacenter | Get-VMHost )){
    Write-Host "ESX: $esxhost"
    $esxcli = Get-EsxCli -VMhost $esxhost    
    $esxcli.system.syslog.reload()
}

or
foreach ($esxhost in (Get-Cluster -Name $cluster | Get-VMHost )){
    Write-Host "ESX: $esxhost"
    $esxcli = Get-EsxCli -VMhost $esxhost    
    $esxcli.system.syslog.reload()
}

No comments:

Post a Comment