VMware: Configure vSphere hosts to VMware Syslog Collector with PowerCLI
PowerCLI script:
#====================================================================# # SCRIPT: PowerCLI_configure_syslog_settings_host.ps1 # # FUNCTION: Add remote syslog server, settings and open # # firewall ports in cluster # # OWNER: Sander Daems # # VSPHERE: 5.5 build 1331820 # # CREATED: 18/12/2013 # # MODIFIED: 18/12/2013 # # VERSION: v.1.0 # #====================================================================# # CHANGELOG: # # # # v.1.0 # # - Script created; # # # #====================================================================# # CUSTOM DEFINITIONS # #====================================================================# $vCenterServer = Read-Host "Enter vCenter Hostname / IP" $vmhost = Get-VMHost #====================================================================# # HOST - Specify host and connect # #====================================================================# Connect-VIServer $vCenterServer #====================================================================# # SCRIPT - SYSLOG - Update Syslog settings # #====================================================================# $vmhost | Set-VMHostAdvancedConfiguration -NameValue @{'Config.HostAgent.log.level'='info';'Vpx.Vpxa.config.log.level'='info';'Syslog.global.logHost'='udp://10.180.200.18:514'} #====================================================================# # SCRIPT - FIREWALL - Open ESXi firewall port # #====================================================================# $vmhost | Get-VMHostFirewallException -VMhost $vmhost -name syslog | Set-VMHostFirewallException -Enabled $true #====================================================================#
vCenter Syslog Collector settings:
Script result:
I believe that last line in the script should be just this –
Get-VMHostFirewallException -VMhost $vmhost -name syslog | Set-VMHostFirewallException -Enabled $true
When I’ve tried the original script it gave an error. The above line worked.
Thanks for the update Ed!