When you create a new VM with powershell and you want to change the boot order Most people will choose for the GUI. Open the settings page of the Virtual machine and moving up and down the boot order.
But there is another option use Powershell. It’s not hard to do, I will show you:
- Run Powershell as administrator
- The bootorder is stored in the firmware of the VM as can be seen when executing
Get-VMFirmware <name of vm>
- To see more details about the bootable devices and the bootorder I create a variable with the name
$win10g2 = Get-VMFirmware <name of vm>
- With the created variable we can get more information about the bootorder by entering
$win10g2.bootorder
In the overview we see the bootorder:
- Harddrive 0
- VMNetworkAdapter 1
- DVDDrive 2
- To rearrange the bootorder, first we need to store the devices in variables. This can be done by using the current bootorder:
$hddrive = $win10g2.BootOrder[0] $pxe = $win10g2.BootOrder[1] $dvddrive = $win10g2.BootOrder[2]
- Now the new order can be set by using the Set-VMFirmware command
Set-VMFirmware -VMName Win10-gen2 -BootOrder $dvddrive,$hddrive,$pxe
- To check if the bootorder has change we can use the command we used at step 2 or step 4:
Get-VMFirmware Win10-gen2
$win10g2.BootOrder
More about Hyper-V in Powershell
Nice documentary about this topic. It helps me a lot to change the boot order for a VM in hyper-V.
Great work!
best regards
Nick
Thanks for the great article!
Thanks for a great article! Real easy to get the hang of how it works.
It saved me tons of time.
Best regards
// Kim
Thanks for the compliment!
awesome mate!!