VMware: Configure vSphere hosts to VMware Syslog Collector with PowerCLI

2

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:

 

image


Script result:

image

image

About Author

2 thoughts on “VMware: Configure vSphere hosts to VMware Syslog Collector with PowerCLI

  1. 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.

  2. Ed Zielinski :

    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!

Leave a Reply

Your email address will not be published. Required fields are marked *