######################################################################################################## # 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