Showing posts with label set-vmhostadvancedconfiguration. Show all posts
Showing posts with label set-vmhostadvancedconfiguration. Show all posts

Tuesday, December 4, 2012

Changing VMware ESXi 5.1 Syslog settings via PowerCLI

Here is a quick and easy method to change the syslog settings on multiple ESX hosts using PowerCLI. First connect to your VC in PowerCLI and then run the below to see your current remote syslog server on each of the ESXi Hosts:

get-vmhost | Get-VMHostAdvancedConfiguration -Name Syslog.global.logHost

After getting that information you can then push out new changes:

#Get Each Host Connected to the vC
foreach ($myHost in get-VMHost)
{
    #Display the ESXi Host that you are applying the changes to
    Write-Host '$myHost = ' $myHost

    #Set the Syslog LogHost
    Set-VMHostAdvancedConfiguration -Name Syslog.global.logHost -Value 'server.domain.com,server2.domain.com' -VMHost $myHost
  
    #Use Get-EsxCli to restart the syslog service
    $esxcli = Get-EsxCli -VMHost $myHost
    $esxcli.system.syslog.reload()

    #Open the firewall on the ESX Host to allow syslog traffic
    Get-VMHostFirewallException -Name "syslog" -VMHost $myHost | set-VMHostFirewallException -Enabled:$true
}


For more information on set-VMHostAdvancedConfiguration take a look at https://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Set-VMHostAdvancedConfiguration.html