Skip to content

Instantly share code, notes, and snippets.

@Dapacruz
Last active October 16, 2018 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dapacruz/8f6a212f70aa0200cc6acd0045d8e38a to your computer and use it in GitHub Desktop.
Save Dapacruz/8f6a212f70aa0200cc6acd0045d8e38a to your computer and use it in GitHub Desktop.
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 Syslog.global.logDir | 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