vSphere Syslog Script

I was working with a client recently who needed to route all their vSphere host’s syslogs to their Log Insight Manager server. I decided to write a script to automate the process. Hope this helps! You will need a machine with VMware’s PowerCLI installed <Tested on 6.5 Release 1 (Build 4624819)> to execute this script with the following parameters:

Script Syntax:

SysLogCfg <vCenter Server> <Admin Username> <Password> <vCenter Cluster Name> <SysLog Server IP>


# This script will set a Syslog Server all all ESXi hosts within a vCenter once connected.
# Seems to run a little more cleaner with this cmdlet and doesn't ask for confirmation
# Created by Jeremy Wheeler
# 01/17/2018

Connect-VIserver -Server $Server -User $User -Password $Password
$sys = 'udp://' + $SysLogN + ':514'
$cl = get-cluster $ClusterN| get-vmhost

foreach($h in $cl){
  Set-VMHostSysLogServer -VMHost $h.name -SysLogServer $sys
  Write-Host 'vSphere Host: ' $h.name
  $syslog = Get-VMHostFirewallException -name ‘syslog’ -vmhost $h.name
  $syslog | Set-VMHostFirewallException -Enabled:$true

You can validate the script worked by checking one of the hosts in the cluster:

Script download link: SysLogCfg