<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Enable syslog and ports in ESXi firewall after configuring syslog. in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944325#M109603</link>
    <description>&lt;P&gt;The script below enables syslog on an ESXi host (server, port, protocol) but it does not actually enable syslog in the ESXi firewall. I have searched here but somehow unable to find a script that can do that. Can someone please help improve upon this script to do that? Thank you.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;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()
    if($esxcli.system.syslog.config.set.Invoke($sLog)){
        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
            })
     }
     else{
        Write-Error "Syslog configuration failed on $($esx.Name)"
    }
} | Export-Csv -Path "c:\file.csv" -NoTypeInformation -UseCulture&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 16 Dec 2022 15:31:56 GMT</pubDate>
    <dc:creator>BBB36</dc:creator>
    <dc:date>2022-12-16T15:31:56Z</dc:date>
    <item>
      <title>Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944325#M109603</link>
      <description>&lt;P&gt;The script below enables syslog on an ESXi host (server, port, protocol) but it does not actually enable syslog in the ESXi firewall. I have searched here but somehow unable to find a script that can do that. Can someone please help improve upon this script to do that? Thank you.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;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()
    if($esxcli.system.syslog.config.set.Invoke($sLog)){
        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
            })
     }
     else{
        Write-Error "Syslog configuration failed on $($esx.Name)"
    }
} | Export-Csv -Path "c:\file.csv" -NoTypeInformation -UseCulture&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Dec 2022 15:31:56 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944325#M109603</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-12-16T15:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944350#M109607</link>
      <description>&lt;P&gt;Did you try adding a line like this?&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;Get-VMHostFireWallException -VMHost $esx -Name Syslog | 
Set-VMHostFirewallException -Enabled:$True.&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Dec 2022 17:35:16 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944350#M109607</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-12-16T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944366#M109612</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.vmware.com/t5/user/viewprofilepage/user-id/256147"&gt;@LucD&lt;/a&gt;&amp;nbsp;. I was able to add that to the script and it worked, however the export had empty rows. Also, I believe a reload command is needed after updating the syslog server and port, and also the syslog ESXi firewall to prevent having to reboot. So I added more lines to the script. I am currently getting the following error when I run it, and I have tried various things but am still getting similar errors:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;At line:29 char:3
+         $esxcli.network.firewall.refresh.Invoke(@{rulesetid='syslog'; ...
+         ~~~~~~~
Missing closing ')' after expression in 'if' statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndParenthesisAfterStatement&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Below is the script. I basically want it to perform the reloads I mentioned above, and also if possible, export the new firewall ruleset value as well. Thanks.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 19:54:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944366#M109612</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-12-16T19:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944371#M109615</link>
      <description>&lt;P&gt;There are a couple of misaligned parentheses and a missing curly brace.&lt;BR /&gt;This seems to be working for me syntax-wise&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;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&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 20:44:01 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944371#M109615</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-12-16T20:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944403#M109619</link>
      <description>&lt;P&gt;Thank you. The script appeared to update the syslog settings and enabled the syslog firewall service, but it displayed the output below in red:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:27 char:13
+             $esxcli.system.syslog.reload.invoke($sLog)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException
 
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At H:\Files\Scripts\vSphere\syslog\esxi-syslog-configure.ps1:29 char:17
+ ...             $esxcli.network.firewall.refresh.Invoke(@{rulesetid = 'sy ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : System.FormatException&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Also, the report generated but only had the "FirewallRulesetNew" column, which was empty. Then I noticed that it didn't have a&amp;nbsp;FirewallRulesetOld column so I added it to the script but it still failed with the same error, although it now has that column in the report and it too is empty. Could this just be that there's no way to properly display the syslog ruleset value?&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 04:24:30 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944403#M109619</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-12-17T04:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944417#M109620</link>
      <description>&lt;P&gt;There are a couple of mistakes in there.&lt;BR /&gt;The reload and refresh methods do not require arguments.&lt;BR /&gt;You should suppress the Booleans returned from entering in your CSV by redirecting the result to Out-Null&lt;BR /&gt;The firewall list method only has a Name and Enabled property in the returned object.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;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&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 09:02:42 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944417#M109620</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-12-17T09:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Enable syslog and ports in ESXi firewall after configuring syslog.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944628#M109636</link>
      <description>&lt;P&gt;Thank you as usual&amp;nbsp;&lt;a href="https://communities.vmware.com/t5/user/viewprofilepage/user-id/256147"&gt;@LucD&lt;/a&gt;&amp;nbsp;. The script works by specifying TRUE or FALSE for FirewallRulesetOld and&amp;nbsp;FirewallRulesetNew now. Sincerely appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 17:35:18 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Enable-syslog-and-ports-in-ESXi-firewall-after-configuring/m-p/2944628#M109636</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-12-19T17:35:18Z</dc:date>
    </item>
  </channel>
</rss>

