Skip to content

Instantly share code, notes, and snippets.

Last active October 16, 2018 21:29
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Redirect VMware ESXi Host Logs
$hosts = '*'
$datastore_name = 'NS-VMFS-01'
$datastore = Get-Datastore -Name $datastore_name | Select-Object -First 1
$log_dir = '[{0}] Logs' -f $datastore.Name
$scratch_location = '{0}/Logs' -f $datastore.ExtensionData.Info.Url -replace 'ds://'
foreach ($h in (Get-VMHost $hosts | Sort-Object -Property Name)) {
Write-Host "$($h.Name): Redirecting log files ..."
$result = Get-AdvancedSetting -Entity $h -Name | Set-AdvancedSetting -Value "$log_dir/$h" -Confirm:$false
Write-Host "New syslog location: $($result.Value)"
$result = Get-AdvancedSetting -Entity $h -Name ScratchConfig.ConfiguredScratchLocation | Set-AdvancedSetting -Value "$scratch_location/$h" -Confirm:$false
Write-Host "New scratch location: $($result.Value)`n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment