VMware Cloud Community
gman7777
Contributor
Contributor
Jump to solution

script needed to retrieve Syslog settings from hosts

Dees anyone have a script  to retrieve Host Syslog settings? The output file should contain  hostname and syslog entry. I do not want to change the settings automatically, I only want to check to ensure that all hosts have a entry.


Thank you

0 Kudos
1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, -

You can employ the Get-VMHostSyslogServer cmdlet to get this info.  Like:

Get-VMHost | %{$oSyslogEndpoint = Get-VMHostSysLogServer -VMHost $_; Select-Object -InputObject $_ `
    name,@{n
="SyslogSrv"; e={$oSyslogEndpoint.Host}},@{n="SyslogPort"; e={$oSyslogEndpoint.Port}}}

That would output something like:

Name                  SyslogSrv    SyslogPort
----                  ---------    ----------
myHost0    oursyslogSrv.dom.com           514
myHost1    oursyslogSrv.dom.com           514
myHost2
myHost3    oursyslogSrv.dom.com           514

...where there are no values for SyslogSrv and SyslogPort if the VMHost has no Syslog server configured.  And, if you want to export that to a file, you can append " | Export-Csv c:\temp\VMHostSyslogInfo.txt -UseCulture -NoTypeInfo" to the end.  That do it for you?

View solution in original post

0 Kudos
2 Replies
mattboren
Expert
Expert
Jump to solution

Hello, -

You can employ the Get-VMHostSyslogServer cmdlet to get this info.  Like:

Get-VMHost | %{$oSyslogEndpoint = Get-VMHostSysLogServer -VMHost $_; Select-Object -InputObject $_ `
    name,@{n
="SyslogSrv"; e={$oSyslogEndpoint.Host}},@{n="SyslogPort"; e={$oSyslogEndpoint.Port}}}

That would output something like:

Name                  SyslogSrv    SyslogPort
----                  ---------    ----------
myHost0    oursyslogSrv.dom.com           514
myHost1    oursyslogSrv.dom.com           514
myHost2
myHost3    oursyslogSrv.dom.com           514

...where there are no values for SyslogSrv and SyslogPort if the VMHost has no Syslog server configured.  And, if you want to export that to a file, you can append " | Export-Csv c:\temp\VMHostSyslogInfo.txt -UseCulture -NoTypeInfo" to the end.  That do it for you?

0 Kudos
gman7777
Contributor
Contributor
Jump to solution

that was the ticket!

Thank You so much

0 Kudos