Configuring a syslog folder is convenient for troubleshooting ESXi. But it’s a pain you-know-where to configure manually across all your ESXi servers. Luckily, PowerCLI can help out. This script creates a folder on the local datastore and configures ESXi to write the syslog in that folder.
Enjoy!
Hugo
#Folder name you like $syslogFolderName = "syslog" #Connect to vCenter Connect-VIServer vcenter.domain.local #Loop through hosts ForEach ($vmhost in Get-VMHost) { #Get only the first part of the FQDN (only if you used the FQDN to add the ESX server to vCenter) $hostname = $vmhost.name.split(".")[0].ToUpper() #Local datastore name (equal to hostname in my case) $datastorename = $hostname #Make the local datastore accessible as a PSdrive New-PSDrive -Name $hostname -Root \ -PSProvider VimDatastore -Datastore (Get-Datastore $datastorename) -Scope global #Access the new PSDrive Set-Location $hostname":" #Create the syslog folder New-Item $syslogFolderName -ItemType directory #Set the advanced parameter to configure the syslog on the local datastore $value = "[$datastorename] $syslogFoldername/$hostname.log" Set-VMHostAdvancedConfiguration -VMHost $vmhost -Name "Syslog.Local.DatastorePath" -Value $value #Cleanup Set-Location $PSHOME Remove-PSDrive $hostname Clear-Variable hostname -ErrorAction SilentlyContinue Clear-Variable datastorename -ErrorAction SilentlyContinue Clear-Variable value -ErrorAction SilentlyContinue } #Disconnect from vCenter Disconnect-VIServer -confirm:$false
Related posts:

Hi hugo,
Apologies for a slightly off-topic question.
I am having an issue with the “get-vm” command being very slow on the FIRST time its run only.
I’m just wondering based on your experience how long does the get-vm command usually take on the FIRST run based on the given number of VMs in the vCenter inventory?
Also, what advice can you give me around building a high performing environment where the get-vm command is very fast even on the first run… is it simply a matter of getting very fast cpu/memory/hard disk etc… or are there fundamental ways of speeding up a simple “get-vm” command on the FIRST time its launched? Note – get-vm runs quickly on subsequent runs, I’m specifically querying around speeding up the first run…
Appreciate any insight you can provide,
regards
marc
Marc,
Make sure you are using the latest versions of powershell and powercli. You can benchmark the performance of the cmdlet using Measure-Command {Get-VM}.
You can get more people to compare against your speed on the vmware communities at http://www.vmware.com/go/powercli.
I am also sure google can find more people with the same question.
Good luck,
Hugo
Hey Marc,
Here’s your answer!
http://blogs.vmware.com/vipowershell/2011/06/how-to-speed-up-the-execution-of-the-first-powercli-cmdlet.html
Hugo