VMware Cloud Community
chicagovm
Enthusiast
Enthusiast
Jump to solution

PowerCLI 5.0 - Syslog results

POWERCLI assistance please.

So, I am confused as to why the NAME does NOT result in the hostname, yet rather Syslog.global.logHost

How does I get the vSphere host name to be listed with the Value? Basically looking to get the value of each vSphere host.


PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-Cluster QA | Get-VMHost | Get-VMHostAdvancedConfiguration -Name Syslog.global.logHost

Name                           Value
----                           -----
Syslog.global.logHost          udp://xxlogger.xxx.com:514
Syslog.global.logHost          xxlogger.xxx.com
Syslog.global.logHost          xxlogger.xxx.com

Thx

0 Kudos
1 Solution

Accepted Solutions
ssbkang
Enthusiast
Enthusiast
Jump to solution

Try this:

foreach ($esxi in (Get-Cluster -Name QA | Get-VMHost | Sort Name)) { $esxi | Select Name, @{N="Syslog";E={Get-VMHostSysLogServer -VMHost $esxi | %{$_.Host + ":" + $_.Port}}}}

View solution in original post

0 Kudos
5 Replies
ssbkang
Enthusiast
Enthusiast
Jump to solution

Try this:

foreach ($esxi in (Get-Cluster -Name QA | Get-VMHost | Sort Name)) { $esxi | Select Name, @{N="Syslog";E={Get-VMHostSysLogServer -VMHost $esxi | %{$_.Host + ":" + $_.Port}}}}

0 Kudos
tomtom901
Commander
Commander
Jump to solution

Get-VMHostAdvancedConfiguration is a deprecated command. This PowerCLI should do the trick. This command is quicker than the command of ssbkang as he uses the port as a seperate value. My command just grabs the configuration from the advanced settings of the vSphere host. NB, you need to change the clustername back to QA in my example.

Get-Cluster -Name Mini | Get-VMHost | Select Name, @{N="Syslog logHost";E={(Get-Advanced Setting -Entity $_ -Name "Syslog.global.logHost").Value}}

And provides output like this:

Name                                    Syslog logHost

----                                    --------------

mini1.vcaplab.local                     192.168.1.10

mini2.vcaplab.local                     192.168.1.10

Hope this helps,

Tom

0 Kudos
chicagovm
Enthusiast
Enthusiast
Jump to solution

ODD.. My Syslog logHost results result in blank values.. even the ones with values.

This script for both ESXi 4.1 and 5.0 ?

0 Kudos
chicagovm
Enthusiast
Enthusiast
Jump to solution

This worked superbly. I wish I knew how you figured out to begin your script with  foreach ($esxi in (Get-Cluster -Name...

rather than

Get-Cluster QA | Get-VMHost

0 Kudos
ssbkang
Enthusiast
Enthusiast
Jump to solution

foreach isn't necessary, it can still be started with Get-Cluster QA | Get-VMHost which is eventually the same thing!

The reason why Get-Cluster QA | Get-VMHost | Select Name, @{N="Syslog";E={(Get-AdvancedSetting -Entity $_ -Name "Syslog.Global.LogHost").Value}} doesn't work for ESXi 4.1 is that the name of the syslog field has been changed:

  • ESXi 5.0 => Syslog.Global.LogHost
  • ESXi 4.1 => Syslog.Remote.Hostname

Which means, you will need to run the command twice:

  1. For ESXi 5.0 => Get-Cluster -Name QA | Get-VMHost | Select Name, @{N="Syslog";E={(Get-AdvancedSetting -Entity $_ -Name "Syslog.Global.LogHost").Value}}
  2. For ESXi 4.1 => Get-Cluster -Name QA | Get-VMHost | Select Name, @{N="Syslog";E={(Get-AdvancedSetting -Entity $_ -Name "Syslog.Remote.Hostname").Value}}

Hope this helps,

Steven.

0 Kudos