VMware Communities > Developer Community > VI Toolkit (for Windows) > Discussions

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
2 Replies Last post: Nov 23, 2008 11:17 PM by LucD
Reply

Write value to vmx files

Nov 23, 2008 9:44 PM

Click to view lldmka's profile Enthusiast lldmka 91 posts since
Jan 15, 2006
Hi,

Complete newbie to the VI Toolkit... but I thought the following (copied from a VI Powershell blog) would write the bios.bootDelay value to my test VMs:

connect-viserver testvc
$key = "bios.bootDelay"
$value = "5000"
get-vm test* | foreach {
$vm = Get-View $_.Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key=$key
$vmConfigSpec.extraconfig[0].Value=$value
$vm.ReconfigVM($vmConfigSpec)
}

However it doesn't do anything more than connect to the VirtualCenter server. Any help appreciated.

Reply Re: Write value to vmx files Nov 23, 2008 10:57 PM
Click to view hugopeeters's profile Hot Shot hugopeeters 137 posts since
Jan 10, 2008
When you dot-source the script (eg type the script name preceded by a dot and a space), you can investigate which variables have which values.
My guess is the $vm is not getting set, because Get-View $_.Id is "the old way". Try replacing that line with $vm = $_ | Get-View
Reply Re: Write value to vmx files Nov 23, 2008 11:17 PM
Click to view LucD's profile Master LucD 858 posts since
Oct 31, 2005
I think you can't use the extraconfig object to change the BIOS settings this way.
In the extraConfig property of the VirtualMachineConfigSpec object it say:
"Configuration keys that would conflict with parameters that are explicitly configurable through other fields in the ConfigSpec object are silently ignored.".

You will have to use the bootOptions property to change this value.
Something like this:

$value = "5000"
get-vm MVV30* | foreach {
	$vm = Get-View $_.Id
	$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
	$vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
	$vmConfigSpec.BootOptions.BootDelay = $value
	$vm.ReconfigVM_Task($vmConfigSpec)
}

Actions