- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are a couple of misaligned parentheses and a missing curly brace.
This seems to be working for me syntax-wise
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($sLog)
if ($esxcli.network.firewall.ruleset.set.Invoke(@{rulesetid = 'syslog'; enabled = $true })){
$esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'syslog'; enabled = $true })
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
FirewallRulesetNew = $esxcli.network.firewall.ruleset.list.Invoke(@{rulesetid = 'syslog' }).RemoteHost
})
}
}
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