Solving problems invented by others...
Powercli one-liner to enable Syslog

Powercli one-liner to enable Syslog

Today i had to activate syslog on every ESXi host. Of course it is possible to configure it via Hostprofiles, and of course i forgot to configure it when i updated my hosts to ESXi 6 a few weeks ago. (Shame on me…)

So first i reconfigured the Hostprofiles. But then i don´t want to put every host into maintenance mode to be able to apply the Hostprofile. Instead i searched a solution to change this settings while the host is in production.


What i created was a Powercli one-liner which i want to share with you:

Get-Cluster -Name "myClusterName" | Get-VMHost | foreach { $curHost = $_; Get-AdvancedSetting -Entity $curHost -Name Config.HostAgent.log.level | Set-AdvancedSetting -Value info -Confirm:$false; Get-AdvancedSetting -Entity $curHost -Name Vpx.Vpxa.config.log.level | Set-AdvancedSetting -Value info -Confirm:$false; Get-VMHostFirewallException -VMHost $curHost -Name syslog | Set-VMHostFirewallException -Enabled:$True; Get-AdvancedSetting -Entity $curHost -Name | Set-AdvancedSetting -Value "udp://syslog.server.fqdn:514" -Confirm:$false }

This script does:

  • Set “Host Agent Log Level” -> Info
  • Set “vCenter Agent Log Level” -> Info
  • Set the name of the Syslog Host
  • Activate the Firewall rule to allow Syslog traffic


Happy scripting…