Skip to content

Instantly share code, notes, and snippets.

@startergo
Created May 26, 2024 19:05
Show Gist options
  • Save startergo/5664407f89057ad09448f244376a5b3d to your computer and use it in GitHub Desktop.
Save startergo/5664407f89057ad09448f244376a5b3d to your computer and use it in GitHub Desktop.
Use Powershell to Remove Network Boot Devices from the Boot Order

##Use Powershell to Remove Network Boot Devices from the Boot Order You can use PowerShell to strip the Network BootTypes from the VMs boot order.

###Extract the Current Boot Order Using Powershell you can use this command to extract the current boot order:

    $old_boot_order = Get-VMFirmware -VMName testvm -ComputerName MyHyperVHost `
                      | Select-Object -ExpandProperty BootOrder

If you inspect $old_boot_order You should see the list of boot devices for testvm. Something like this:

enter image description here

###Strip the Network Boot Devices

You can strip the boot devices from the boot list with the Network BootType using this command:

    $new_boot_order = $old_boot_order | Where-Object { $_.BootType -ne "Network" }

Inspecting $new_boot_order should look something like this with no more Network boot devices:

enter image description here

###Set the New Boot Order

To set the new boot order for the VM use this command:

    Set-VMFirmware -VMName testvm -ComputerName MyHyperVHost -BootOrder $new_boot_order

###Confirm the New Boot Order

To confirm what you did use that first Get-VMFirmware command again:

    Get-VMFirmware -VMName testvm -ComputerName MyHyperVHost `
    | Select-Object -ExpandProperty BootOrder


Beware: If you use both PowerShell and Hyper-V manager to make changes to the boot order, PowerShell may report erroneous (out-of-date) boot order. See also this technet thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment