The following script enables PXE boot for al the VM’s in a particular folder. After running this script, the VM’s are set to boot only from PXE, so all other options are disabled. The original part of the script is created by LucD and posted on de VMTN forums. See the source for more information.
enable-pxeboot-vm.ps1
$VC = Connect-VIServer (Read-Host "Enter vCenter server") $folder = (Read-Host "Enter folder name") $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" $vms = Get-Folder -Name $folder | Get-VM foreach ($vm in $vms){ (get-view ($vm).ID).ReconfigVM_Task($spec)} Disconnect-VIServer -Confirm:$False
If you want to return to the default settings, you can run the next script:
disable-pxeboot-vm.ps1
$VC = Connect-VIServer (Read-Host "Enter vCenter server") $folder = (Read-Host "Enter folder name") $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.extraConfig += New-Object VMware.Vim.OptionValue $spec.extraConfig[0].key = "bios.bootDeviceClasses" $spec.extraConfig[0].value = "allow:hd,cd,fd" $vms = Get-Folder -Name $folder | Get-VM foreach ($vm in $vms){ (get-view ($vm).ID).ReconfigVM_Task($spec)} Disconnect-VIServer -Confirm:$False
Source: LucD @ http://communities.vmware.com/thread/196651
Very nice.
Good article on how to make the change to boot from pxe, crap there is no support in the vi toolkit (that we can see) to enforce a boot order eg: net,hd is the same as hd,net. Would love to see this sorted in a future release! 🙂