Tips and Tricks – Vitual Machine advanced settings
Few days back I found very useful PowerCLI script which allow add advance setting to virtual machine without power it down. I thought it might be useful for someone so I decided to document it. Standard process for adding new advance setting is as follows:
- power VM down
- add advance setting to VM
- power VM on
Using below script you can add advance setting to VM without power it down ! The only thing which you have to do after script execution, is do virtual machine vMotion.
$vm = Get-View (Get-VM virtual_machine_name).ID
$CfgSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$CfgSpec.extraconfig = New-Object VMware.Vim.optionvalue
# you can use any advanced setting key/value pair here:
In the example below RemoteDisplay.maxConnections=1 advance value was added to VM. It will limit concurrent VM console connections to 1.
- Run a script, in a Recent task window new task appears: Reconfigure virtual machine – wait until task complete.
- vMotion VM between ESX hosts
- check if advance setting was applied, try to open VM console from two vSphere clients
As you can see on above item, advance setting was applied successfully to virtual machine configuration without powering VM down.