Search This Blog

Thursday 17 December 2009

PowerCLI to alter VM BIOS setting



I've been asked by a client how to change the BIOS boot order of a Virtual Machine so that they can PXE boot it first to build it, and then change it to boot from the hard disk afterwards.

So, I've not discovered any information where it is possible to actually change the order of boot devices, but it IS possible to allow/disallow certain devices. So, the code is as follows


Connect-VIServer ipaddress
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:net"

(get-view (Get-VM -Name "Virtual Machine").ID).ReconfigVM_Task($spec)

1 comment:

Anonymous said...

Hello.

After a lot of trial and error I was able to figure out how to set the BIOS boot order of a VM via PowerCLI:


Connect-VIServer -Server

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.extraConfig += New-Object VMware.Vim.OptionValue

$spec.extraConfig[0].key = "bios.bootOrder"

$spec.extraConfig[0].value = "ethernet0"

(Get-View (Get-VM -Name ).ID).ReconfigVM_Task($spec)


Thanks for setting me down the correct path.

Regards,

-=Alex

Alex St. Amand
Sr. Systems Engineer, VCP | Enterprise Virtualization | AMD