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.
Connect-VIServer vCenter_server_name $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: $CfgSpec.extraconfig[0].Key="RemoteDisplay.maxConnections" $CfgSpec.extraconfig[0].Value="1" $vm.ReconfigVM($CfgSpec)
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.
Hi,
A version for multiple settings here http://ict-freak.nl/2009/07/08/powercli-add-multiple-values-to-a-vmx-file/
Looks awesome, never thought that this is even possible, thanks!
Also, there’s a typo in title: Vitual instead of Virtual