PowerCLI: Configure Log rotation and size options for vmware.log

By default, the virtual machine log file (vmware.log) is rotated as a result of the virtual machine’s Power On or Power Off operation. , In order to limit the total size this can grow to you may configure the log you may configure a log rotation size and level of rotation.

Also, this can add a level of protection where denial of service attack could write information to a log entry where these limits are not configured,as uncontrolled logging could lead to denial of service due to the datastore’s being filled.

In the below example, I am going to configure each VM to have a log rotate size of ‘1,000’ KB (the configuration value is in bytes, so 1,024,000) and set the level of rotation to ’10’. This can be achieved by adding the following to each VMs configuration parameters (VM Options > Advanced).

log.KeepOld = 10
log.rotatesize = 1024000

As I want to configure these settings for a large number of VMs, I can achieve this by using PowerCLI to build a collection of VMs at a cluster object level and then add these settings.

Firstly, we will connect to our vCenter server and build a collection of VMs from a single cluster by invoking the Get-VM cmdlet.

For Each VM returned in the collection, we will now add the configuration settings as above, by invoking the cmdlet New-AdvancedSetting specifying the name and value, where the ‘Confirm’ parameter value is False to prevent the script block requiring user interaction.