Last active
October 16, 2018 21:29
-
-
Save Dapacruz/8f6a212f70aa0200cc6acd0045d8e38a to your computer and use it in GitHub Desktop.
Redirect VMware ESXi Host Logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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