PeetersOnline.nl
Configure Syslog on Local Datastore with PowerCLI
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 |
3 Responses to Configure Syslog on Local Datastore with PowerCLI
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





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