Using PowerCLI to set the Global System Log Location

Are you seeing an error stating that the System Logs on your host(s) are stored on non-persistent storage.

Following THIS VMware KB article, I knew I had to change the Global Logdir.

What we did was create a shared datastore called ESXiScratch. On this datastore, we created folders for each host.


Next, I ran the following PowerCLI command to set the value. Make sure to specify YOUR datastore name in-between the brackets below.

 Get-VMhost lab01.lab.local | Get-AdvancedSetting -Name | Set-AdvancedSetting -Value "[ESXiScratch] .locker-lab01" 

Next, we need to set the value to true.

 Get-VMhost lab01.lab.local | Get-AdvancedSetting -Name | Set-AdvancedSetting -Value $True

If you wanted to do this to a whole cluster, I would do something like this…

# Get the VMhosts in the cluster
$vmhosts = Get-Cluster LAB | Get-VMHost

# Assign the Datastore Name to Variable
$SyslogDatastore = "ESXiScratch"

# Take the datastore name and add brackets around it
$syslogDatastoreLogDir = "[" + $SyslogDatastore + "]"

# Loop through each of the hosts in the cluster
foreach ($vmhost in $vmhosts) {
     # Set the variable to the name of the folder.  The vmhost syntax removes the domain name 
     $SysLogFolderName = ".locker-" + ($ -replace '(.+?)\..+','$1')

     # This variable combines all of the above to the full logdir path
     $FullLogPath = $SyslogDatastoreLogDir + " " + $syslogfoldername

     # Set the Syslog Global Logdir value
     get-vmhost $vmhost | Get-AdvancedSetting -Name "" | Set-AdvancedSetting -Value $FullLogPath

     # Set the Syslog Global LogdirUnique value
     get-vmhost $vmhost | Get-AdvancedSetting -Name "" | Set-AdvancedSetting -Value $True

Finally, you need to REBOOT the host for the changes to take effect.


Ben Liebowitz, VCP, vExpert
NJ VMUG Leader

Share This:

Leave a Reply

Your email address will not be published.

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