Using PowerCLI to change the Syslog server for your ESX host.

I recently discovered SexiLog to use with VMware ESX host.  I needed a quick and easy way to change where the ESX host sent there logs to.  Doing some google searches I was able to put together a quick PowerCLI script.  In about 5 minutes I was able to change the syslog for all of my ESX host.

$ESXLOG = “1.2.3.4”
Get-VMHost | Foreach {
Write-Host “Adding $ESXLOG as Syslog server for $($_.Name)”
$SetSyslog = Set-VMHostSysLogServer -SysLogServer $ESXLOG -SysLogServerPort 514 -VMHost $_
Write-Host “Reloading Syslog on $($_.Name)”
$Reload = (Get-ESXCLI -VMHost $_).System.Syslog.reload()
Write-Host “Setting firewall to allow Syslog out of $($_)”
$FW = $_ | Get-VMHostFirewallException | Where {$_.Name -eq ‘syslog’} | Set-VMHostFirewallException -Enabled:$true
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: