Configure local syslog folder on all your ESXi servers

########################################################################################################
# Steps to use the script:                                                                             #
# 1st: create a folder on an shared datastore                                                          # 
# 2nd: adjust the content of the variable $FolderName to the name of the folder created in step 1      #
# 3rd: adjust the content of the variable $datastore to the name of the shared datastore               #
# 4th: adjust vCenter IP/Username/Password to match your settings                                      #
########################################################################################################

Connect-VIServer -Server VCIPADDRESS -User USERNAME -Password PASSWORD

$esxihosts = Get-VMHost
$FolderName = "esxi_syslog"
$datastore = "NAMEofSAN"

foreach ($esxi in $esxihosts) {
	$hostname = $esxi.Name.split(".")[0]
	$value = "[$datastore] $Foldername/$hostname.log"
	Write-Host $value
	Set-VMHostAdvancedConfiguration -VMHost $esxi -Name "Syslog.Local.DatastorePath" -Value $value
	Clear-Variable hostname -ErrorAction SilentlyContinue
	Clear-Variable value -ErrorAction SilentlyContinue
}
Disconnect-VIServer -Server VCIPADDRESS -Force -Confirm:$false

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.