Using PowerCLI to set the Global System Log Location
- Ben Liebowitz
- 0
- 5666
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.
.locker-lab01
.locker-lab02
etc.
Next, I ran the following PowerCLI command to set the Syslog.global.logdir value. Make sure to specify YOUR datastore name in-between the brackets below.
Get-VMhost lab01.lab.local | Get-AdvancedSetting -Name Syslog.global.logdir | Set-AdvancedSetting -Value "[ESXiScratch] .locker-lab01"
Next, we need to set the Syslog.global.logDirUnique value to true.
Get-VMhost lab01.lab.local | Get-AdvancedSetting -Name Syslog.global.logdirUnique | 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-" + ($vmhost.name -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 "Syslog.global.logdir" | Set-AdvancedSetting -Value $FullLogPath # Set the Syslog Global LogdirUnique value get-vmhost $vmhost | Get-AdvancedSetting -Name "Syslog.global.LogDirUnique" | Set-AdvancedSetting -Value $True }
Finally, you need to REBOOT the host for the changes to take effect.
Thanks,
Ben Liebowitz, VCP, vExpert
NJ VMUG Leader
Share This: