<?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 Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output. in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2932067#M108599</link>
    <description>&lt;P&gt;Many thanks LucD, will try for next post.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 12:57:50 GMT</pubDate>
    <dc:creator>wetnose88</dc:creator>
    <dc:date>2022-10-05T12:57:50Z</dc:date>
    <item>
      <title>Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931809#M108569</link>
      <description>&lt;P&gt;I have this script below (I got it from here) that adds syslog info to servers. It works, but the only output message shows "true" (no quotes) after it runs with ESXi host, vCenter server or any other information. Can someone please help to get the output message to show the vCenter server name, the ESXi host name, the previous syslog server entry, then the new syslog server entry? If this is not possible, could it at least display a "Success" instead of true? I'd still want it to display the vCenter server and ESXi host, then a "Suucess" next to each entry. If the output can also be in a CSV report format that would be very helpful. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#This will prompt you to enter your credentials
$vCenterCredential = Get-Credential -Message "Enter account with access to the vCenter(s)" -ErrorAction SilentlyContinue;

#List of vCenter server(s) in a text file either on local or shared drive location
$vCenters = Get-Content -Path "c:\Scripts\Inputs\vcenters.txt"

#Connect to vCenters
Connect-VIServer -Server $vCenters -Credential $vCenterCredential -Protocol https | Out-Null

#Iterate through all ESXi hosts in all vCenter server(s), and configure the Syslog protocol, server, and port
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$sLog = @{
    loghost = 'tcp://syslog-server:123'
}
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.system.syslog.config.set.Invoke($sLog)
}
#Disconnect from all vCenter server(s)
Disconnect-VIServer -Server $vCenters -Confirm:$false&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 04 Oct 2022 02:47:45 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931809#M108569</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-10-04T02:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931825#M108574</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;#This will prompt you to enter your credentials
$vCenterCredential = Get-Credential -Message "Enter account with access to the vCenter(s)" -ErrorAction SilentlyContinue;

#List of vCenter server(s) in a text file either on local or shared drive location
$vCenters = Get-Content -Path "c:\Scripts\Inputs\vcenters.txt"

#Connect to vCenters
Connect-VIServer -Server $vCenters -Credential $vCenterCredential -Protocol https | Out-Null

#Iterate through all ESXi hosts in all vCenter server(s), and configure the Syslog protocol, server, and port
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $sLog = @{
        loghost = 'tcp://syslog-server:123'
    }
    $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 .\report.csv -NoTypeInformation -UseCulture

#Disconnect from all vCenter server(s)
Disconnect-VIServer -Server $vCenters -Confirm:$false&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 04 Oct 2022 06:10:16 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931825#M108574</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-10-04T06:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931898#M108580</link>
      <description>&lt;P&gt;Excellent! Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 13:37:04 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931898#M108580</guid>
      <dc:creator>BBB36</dc:creator>
      <dc:date>2022-10-04T13:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931986#M108593</link>
      <description>&lt;P&gt;It is time for me to reward the&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://communities.vmware.com/" target="_blank" rel="noopener"&gt;Communities&lt;/A&gt;, I have learned a lot from here&amp;nbsp;silently.&lt;/P&gt;&lt;P&gt;I use PowerCLI ONLY to setup the syslog in all 4 vCenters, tested working as well.&lt;/P&gt;&lt;P&gt;#Configure-SyslogOnMultipleESXiHostsIinMultiplevCenters.ps1&lt;BR /&gt;$Transcript = "$env:USERPROFILE\documents\transcriptForSyslogSettingChanges_$(Get-Date -format yyyy-MM-dd-hh).txt"&lt;/P&gt;&lt;P&gt;$vcenters = "vctrp01.vsphere.local","vctrp02.vsphere.local","vctrp03.vsphere.local","vctrp04.vsphere.local"&lt;/P&gt;&lt;P&gt;Start-Transcript -path $Transcript -append&lt;BR /&gt;Foreach ($vcenter in $vcenters){&lt;/P&gt;&lt;P&gt;Write-Host "Connectint to $vCenter ......" -ForegroundColor Cyan&lt;BR /&gt;Connect-VIServer -Server $vcenter -User $creds.User -Password $creds.Password&lt;/P&gt;&lt;P&gt;Write-Host "Processing the ESXi host from $vcenter" -ForegroundColor Green&lt;BR /&gt;$vmhosts = get-vmhost&lt;BR /&gt;Foreach ($vmhost in $vmhosts){&lt;/P&gt;&lt;P&gt;Write-Host "Processing the ESXi host $vmhost from $vcenter" -ForegroundColor Cyan&lt;BR /&gt;#Comment out line either udp or tcp to fit with your environment&lt;BR /&gt;Get-VMHost $vmhost | Get-AdvancedSetting -Name Syslog.Global.Loghost | Set-AdvancedSetting -Value udp://10.115.20.100:514 -Confirm:$false&lt;BR /&gt;Get-VMHost $vmhost | Get-AdvancedSetting -Name Syslog.Global.Loghost | Set-AdvancedSetting -Value tcp://10.115.20.100:514 -Confirm:$false&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;Write-Host "Disconnect from $vCenter " -ForegroundColor Yellow&lt;BR /&gt;Disconnect-viserver * -confirm:$false&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Stop-Transcript&lt;BR /&gt;Write-Host "All done successfully, please review the result $Transcript " -ForegroundColor Yellow&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 22:48:20 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931986#M108593</guid>
      <dc:creator>wetnose88</dc:creator>
      <dc:date>2022-10-04T22:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931989#M108594</link>
      <description>&lt;P&gt;BTW, I forget to mention the command I used to connect to vCenter "&lt;SPAN&gt;Connect-VIServer -Server $vcenter -User $creds.User -Password $creds.Password&lt;/SPAN&gt;". I am doing it from a jumper server, and my login account have domain admin privilege and&amp;nbsp;&lt;SPAN&gt;Global Permission from each vCenter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 22:51:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931989#M108594</guid>
      <dc:creator>wetnose88</dc:creator>
      <dc:date>2022-10-04T22:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931997#M108595</link>
      <description>&lt;P&gt;Thank you LucD.&lt;/P&gt;&lt;P&gt;BTW, the code you poster here are colorful and easy to read, how do you achieve that?&lt;/P&gt;&lt;P&gt;I can do it either in Notepad++/Powershell ISE, but once I copy &amp;amp; paste my code here, it is all black.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wetnose88_0-1664936372806.png" style="width: 691px;"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/97641i6875F2D90BB64505/image-dimensions/691x261/is-moderation-mode/true?v=v2" width="691" height="261" role="button" title="wetnose88_0-1664936372806.png" alt="wetnose88_0-1664936372806.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 02:19:50 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2931997#M108595</guid>
      <dc:creator>wetnose88</dc:creator>
      <dc:date>2022-10-05T02:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2932005#M108596</link>
      <description>&lt;P&gt;For code blocks I use the Insert/Edit Code sample button, and then select C# (the closest for decent formatting in the absence of a PowerShell option).&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code-insert.jpg" style="width: 534px;"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/97642i9FBE7419C21CB670/image-size/large?v=v2&amp;amp;px=999" role="button" title="code-insert.jpg" alt="code-insert.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 04:17:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2932005#M108596</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-10-05T04:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2932067#M108599</link>
      <description>&lt;P&gt;Many thanks LucD, will try for next post.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 12:57:50 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2932067#M108599</guid>
      <dc:creator>wetnose88</dc:creator>
      <dc:date>2022-10-05T12:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994931#M113792</link>
      <description>&lt;P&gt;Hi LUCD,&lt;BR /&gt;&lt;BR /&gt;Is there a way we can append the syslog configuration with new IP ,rather than replacing the exisitng ones?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:24:56 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994931#M113792</guid>
      <dc:creator>VishnuN87</dc:creator>
      <dc:date>2023-11-09T13:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994952#M113795</link>
      <description>&lt;P&gt;The loghost property in the has table accepts an array of Strings.&lt;BR /&gt;So you can just append the new host(s) to the old host(s).&lt;BR /&gt;&lt;BR /&gt;Something like this for example&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;#This will prompt you to enter your credentials
$vCenterCredential = Get-Credential -Message "Enter account with access to the vCenter(s)" -ErrorAction SilentlyContinue;

#List of vCenter server(s) in a text file either on local or shared drive location
$vCenters = Get-Content -Path "c:\Scripts\Inputs\vcenters.txt"

#Connect to vCenters
Connect-VIServer -Server $vCenters -Credential $vCenterCredential -Protocol https | Out-Null

# New syslog hosts
$syslogHosts = 'tcp://syslog-newserver1:123', 'tcp://syslog-newserver2:123'

#Iterate through all ESXi hosts in all vCenter server(s), and configure the Syslog protocol, server, and port
Get-VMHost -PipelineVariable esx |
  ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $old = $esxcli.system.syslog.config.get.Invoke()
    $sLog = @{
      loghost = $old.RemoteHost, $syslogHosts 
    }
    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 .\report.csv -NoTypeInformation -UseCulture

#Disconnect from all vCenter server(s)
Disconnect-VIServer -Server $vCenters -Confirm:$false&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:00:19 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994952#M113795</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2023-11-09T15:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994954#M113796</link>
      <description>&lt;P&gt;Thanks LUCD , Yes this will add multiple ,however if we have a syslog server mentioned already in all esxi and we need to append a new one . The syslog Ips are different for each region anyway that can be modified in the script .&lt;BR /&gt;&lt;BR /&gt;After 1 week we will remove the old one so if you can provide your help on that too.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:06:38 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994954#M113796</guid>
      <dc:creator>VishnuN87</dc:creator>
      <dc:date>2023-11-09T15:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Configure syslog on multiple ESXi hosts in multiple vCenters with CSV output.</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994956#M113797</link>
      <description>&lt;P&gt;That should be just removing the old one from the array.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;$oldServer = 'xyz'    
$sLog = @{
   loghost = $old.RemoteHost | where{$_ -ne $oldServer}
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:15:45 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Configure-syslog-on-multiple-ESXi-hosts-in-multiple-vCenters/m-p/2994956#M113797</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2023-11-09T15:15:45Z</dc:date>
    </item>
  </channel>
</rss>

