Too many problems, not enough time.

PowerCLI A Syslog Server To All ESXi Hosts In vCenter

I was recently tasked with configuring all ESXi hosts within a number of vCenter environments to use a Syslog Server. Each of these environments contained numerous clusters and ESXi hosts. Too many to manually want to configure a Syslog Server by hand. Using our lab environment I played around with a few different ways of quickly pushing out some Syslog settings via PowerCLI.

I came across two different PowerCLI cmdlets that would do the job. The first was Set-AdvancedSetting and the second was Set-VMHostAdvancedConfiguration. The latter being a deprecated cmdlet. Both cmlets do the job equally well. Ideally you would want to be using the newer Set-AdvancedSetting cmdlet rather than the deprecate one.

Where I didn’t like the newer Set-AdvancedSetting was that it would ask for confirmation before making a change. I didn’t fully realise how annoying this would be till after I had wrote my script. Once a connection to a vCenter is made in PowerCLI the script I created prompts for a Syslog Server then gets all ESXi hosts in the vCenter, applies the Syslog Server value, reloads syslog, and finally opens the syslog ports. All simple and basic except that you will be prompted to apply the syslog value to each host. Fine if you’re very cautious or if you want to omit specific hosts.

Perform operation?
Modifying advanced setting ‘Syslog.global.logHost’.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):y

I then decided to test out Set-VMHostAdvancedConfiguration and found I preferred this cmdlet over Set-AdvancedSetting. Each time it set a syslog value on a host it would flash up a friendly yellow little warning and go ahead with the change. Much more convenient for large changes. At some point in a future PowerCLI version I assume this cmdlet won’t work but until then it works a treat.