- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are a couple of mistakes in there.
The reload and refresh methods do not require arguments.
You should suppress the Booleans returned from entering in your CSV by redirecting the result to Out-Null
The firewall list method only has a Name and Enabled property in the returned object.
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$sLog = @{
loghost = 'tcp://server.com:1514'
}
$esxcli = Get-EsxCli -VMHost $esx -V2
$old = $esxcli.system.syslog.config.get.Invoke()
$old2 = $esxcli.network.firewall.ruleset.list.Invoke(@{rulesetid = 'syslog' })
if ($esxcli.system.syslog.config.set.Invoke($sLog)) {
$esxcli.system.syslog.reload.Invoke() | Out-Null
if ($esxcli.network.firewall.ruleset.set.Invoke(@{rulesetid = 'syslog'; enabled = $true })){
$esxcli.network.firewall.refresh.Invoke() | Out-Null
New-Object -TypeName PSObject -Property ([ordered]@{
vCenter = ([uri]$esx.ExtensionData.Client.ServiceUrl).Host
VMHost = $esx.Name
SyslogOld = $old.RemoteHost
SyslogNew = $esxcli.system.syslog.config.get.Invoke().RemoteHost
FirewallRulesetOld = $old2.Enabled
FirewallRulesetNew = $esxcli.network.firewall.ruleset.list.Invoke(@{rulesetid = 'syslog' }).Enabled
})
}
}
else {
Write-Error "Syslog configuration failed on $($esx.Name)"
}
} | Export-Csv -Path "c:\file.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference