PowerCLI – esxi log retention configuration

Here is a simple powerCLI script to set individual hosts log values, as said before you must decide these with the security team. I’ve put in some default values according to VMware.

[code language=”powershell”]
# Get and Set AdvancedConfiguration for Host Logs
# russ oct 2015
# Script Gets and Set Host Log size and Rotate Values for a single esx host

# Get-VMhost | Select Name
Write-host "Which host do you want to run this on" -ForegroundColor Yellow
$vmhost = Read-Host "Enter host name"

Write-host "."
Write-host $vmhost -ForegroundColor White
Write-host "———————————————————————–" -ForegroundColor White
Write-host "."

Get-VMHost $vmhost | Get-AdvancedSetting -Name Syslog.Global* | ft -autosize
Get-VMHost $vmhost | Get-AdvancedSetting –Name Syslog.loggers* | ft -autosize
Write-host "."

$HOST.UI.RawUI.ForegroundColor = "DarkGray"

Write-host "."
Get-AdvancedSetting -Entity $vmhost -Name Syslog.global.defaultRotate | Set-AdvancedSetting -Value 16 -Confirm:$false | ft -autosize
Get-AdvancedSetting -Entity $vmhost -Name Syslog.global.defaultSize | Set-AdvancedSetting -Value 10240 -Confirm:$false | ft -autosize
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.auth.rotate  | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize   
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.esxupdate.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize  
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.hostd.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize  
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.shell.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.syslog.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize   
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.usb.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize   
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.vobd.rotate  | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize   
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.vmkernel.rotate  | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize  
Get-AdvancedSetting -Entity $vmhost -Name Syslog.loggers.vmkwarning.rotate | Set-AdvancedSetting -Value 36 -Confirm:$false | ft -autosize   
Write-host "."
Write-host "Done" -ForegroundColor Yellow

$HOST.UI.RawUI.ForegroundColor = "White"
Get-VMHost $vmhost | Get-AdvancedSetting -Name Syslog.Global* | ft -autosize
Get-VMHost $vmhost | Get-AdvancedSetting –Name Syslog.loggers* | ft -autosize
Write-host "."
Write-host "."

$HOST.UI.RawUI.ForegroundColor = "Gray"

 
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *

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