如何检查VMHost是否配置了Syslog转发

时间:2018-06-19 17:51:03

标签: powershell vmware powershell-v4.0 powercli vcenter

我想检查VMHost是否配置了Syslog转发

我已经编写了以下cmdlet,但未提供“ Syslog转发”状态。

$esxcli = Get-EsxCli -VMHost abc.com
$esxcli.system.syslog | Select-Object *

$esxcli.system.syslog | gm返回错误

gm : You must specify an object for the Get-Member cmdlet.
At line:1 char:25
+ $esxcli.system.syslog | gm
+ ~~
    + CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
    + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand

$esxcli.system.syslog.config.get()返回错误:

You cannot call a method on a null-valued expression.
At line:1 char:1
+ $esxcli.system.syslog.config.get()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

1 个答案:

答案 0 :(得分:1)

PowerCLI包含Get-VMHostSysLogServer cmdlet。在您的问题上下文中,此命令将为VMHost abc.com返回Syslog服务器:

Get-VMHostSysLogServer -VMHost abc.com