Hello,
I can set my ESXi5 syslog server settings from the CLI of each server using these commands below:
esxcli system syslog config set --loghost='udp://indexer.domain.com:514'
esxcli system syslog reload
How do I script is so that it makes the change on all ESXi hosts in my vCenter?
Thanks,
Duncan.
I do this way
add-pssnapin vmware.vimautomation.core
Connect-VIServer -Server "vcenterserver" -User "xxx" -Password "xxx"
$loghost = "x.x.x.x"
$esxhosts = Get-VMHost
foreach($esx in $esxhosts){
$hview = Get-View -ViewType "hostsystem" -Filter @{"Name"= $esx.Name}
# ------- HostImageConfigGetAcceptance -------
$_this = Get-View -Id $hview.ConfigManager.ImageConfigManager
$_this.HostImageConfigGetAcceptance()
# ------- EnableRuleset -------
$_this = Get-View -Id $hview.ConfigManager.FirewallSystem
$_this.EnableRuleset("syslog")
# ------- ESXCLI enable syslog -------
$esxcli = Get-EsxCli -vmhost $esx.Name
$esxclisetsyslog = $esxcli.system.syslog.config.set($null, $null, $null, $null, $loghost, $null)
$esxcli.system.syslog.reload()
}
Disconnect-VIServer -Server "vcenterserver" -Confirm:$false
Check the script used in this article using ESXCLI
Configuring Multiple Syslog Servers for ESXi 5
Also take a look at Set-VMHostSysLogServer PowerCLI cmdlet
Hi dbutch1976,
in addition what was written you can aslo take a look on this
http://psvmware.wordpress.com/2012/07/31/configuring-syslog-for-esxi-hosts/
I have also written somethign about presenting directories in more human readable version.
And also a quick extract from the blog post:
"
get
-vmhost
|
Set
-VMHostAdvancedConfiguration
-NameValue
@{
'Config.HostAgent.log.level'
=
'info'
;
'Vpx.Vpxa.config.log.level'
=
'info'
;
'Syslog.global.logHost'
=
'udp://syslogip:514'
}
"
This will change logging level and loghost for each esx box in VC.
Or version which select hosts from clusters
"
get
-cluster
'your_cluster'
|get
-vmhost
|
Set
-VMHostAdvancedConfiguration
-NameValue
@{
'Config.HostAgent.log.level'
=
'info'
;
'Vpx.Vpxa.config.log.level'
=
'info'
;
'Syslog.global.logHost'
=
'udp://syslogip:514'
}
"
Regards,
Greg
I do this way
add-pssnapin vmware.vimautomation.core
Connect-VIServer -Server "vcenterserver" -User "xxx" -Password "xxx"
$loghost = "x.x.x.x"
$esxhosts = Get-VMHost
foreach($esx in $esxhosts){
$hview = Get-View -ViewType "hostsystem" -Filter @{"Name"= $esx.Name}
# ------- HostImageConfigGetAcceptance -------
$_this = Get-View -Id $hview.ConfigManager.ImageConfigManager
$_this.HostImageConfigGetAcceptance()
# ------- EnableRuleset -------
$_this = Get-View -Id $hview.ConfigManager.FirewallSystem
$_this.EnableRuleset("syslog")
# ------- ESXCLI enable syslog -------
$esxcli = Get-EsxCli -vmhost $esx.Name
$esxclisetsyslog = $esxcli.system.syslog.config.set($null, $null, $null, $null, $loghost, $null)
$esxcli.system.syslog.reload()
}
Disconnect-VIServer -Server "vcenterserver" -Confirm:$false
$loghost = "indexer.domain.com"
Thanks for the help everyone, I went with your solution vlife.