Automation being king, this will do it. The general process for each host:
- Set the syslog destination
- Insure a firewall exception
- Restart the syslog service.
In vSphere 5.1 the Set-VMHostSysLogServer cmdlet was added to PowerCLI. While there are other ways to accomplish the same task, I tend to prefer using any method that is more obvious when coding. Set-VMHostSysLogServer it is.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$syslog = 'udp://1.2.3.4:514' # change to your syslog host | |
$Hosts = Get-VMHost | Sort-Object Name | |
$Hosts | ForEach-Object { | |
try { | |
Write-Output "Setting $_ Syslog to $syslog" | |
Set-VMHostSysLogServer -VMHost $_ -SysLogServer $syslog -ErrorAction Stop | Out-Null | |
} | |
catch [Exception] { | |
Write-Output " Operation failed." | |
continue | |
} | |
$res = Get-VMHostSysLogServer -VMHost $_ | |
if ("$($res.Host):$($res.Port)" -eq $syslog) { | |
# the setting took, add firewall exception and restart the service | |
Write-Output " Enabling syslog firewall exception on $_" | |
Get-VMHostFirewallException -VMHost $_ -Name "syslog" | Set-VMHostFirewallException -Enabled:$true | Out-Null | |
Write-Output " Restarting Syslog on $_" | |
$esxCli = Get-EsxCli -VMHost $_ -V2 | |
if ($esxCli.system.sysLog.reload.invoke()) { | |
Write-Output " Reloaded" | |
} | |
} | |
} |