How to change VM bootorder with Powershell

Buy Me a Coffee

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:
  1. Run Powershell as administrator

  1. The bootorder is stored in the firmware of the VM as can be seen when executing

 

Get-VMFirmware <name of vm>

 

  1. To see more details about the bootable devices and the bootorder I create a variable with the name

 

$win10g2 = Get-VMFirmware <name of vm>

 

  1. 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

 

  1. 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]

 

  1. Now the new order can be set by using the Set-VMFirmware command
Set-VMFirmware -VMName Win10-gen2 -BootOrder $dvddrive,$hddrive,$pxe

  1. 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

 

5 thoughts on “How to change VM bootorder with Powershell

  1. Nick

    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

    Reply
  2. Kim

    Thanks for a great article! Real easy to get the hang of how it works.
    It saved me tons of time.

    Best regards
    // Kim

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *