0

I've found this: Changing UEFI boot order from Windows dealing with the UEFI boot order from Windows.

How do I figure out which UUID is which boot device?

Running bootmgr /enum {fwbootmgr} I get the following output on two different machines which are exactly the same brand/type/model:

displayorder            {bdb82af6-097d-11f0-8df2-806e6f6e6963}
                        {bootmgr}
                        {bdb82af1-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af2-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af3-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af4-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af5-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af7-097d-11f0-8df2-806e6f6e6963}
                        {bdb82af8-097d-11f0-8df2-806e6f6e6963}
                        {bdb82aeb-097d-11f0-8df2-806e6f6e6963}
                        {bdb82aec-097d-11f0-8df2-806e6f6e6963}
displayorder            {bootmgr}
                        {37446058-08cd-11f0-8df2-806e6f6e6963}
                        {37446053-08cd-11f0-8df2-806e6f6e6963}
                        {37446054-08cd-11f0-8df2-806e6f6e6963}
                        {37446055-08cd-11f0-8df2-806e6f6e6963}
                        {37446056-08cd-11f0-8df2-806e6f6e6963}
                        {37446057-08cd-11f0-8df2-806e6f6e6963}
                        {37446059-08cd-11f0-8df2-806e6f6e6963}
                        {3744605a-08cd-11f0-8df2-806e6f6e6963}
                        {3744604d-08cd-11f0-8df2-806e6f6e6963}
                        {3744604e-08cd-11f0-8df2-806e6f6e6963}

The upper one is set to boot from network (Realtek USB LAN UEFI IPv4 or something it's called on those machines, it's the LAN device of a Thunderbolt dock); the lower one is booting local Windows first. As I mentioned, they're two machines which are otherwise identical (make/model/type - Lenovo P16v Gen1 / 21FC).

How do I figure out - bar trial and error, which is out of the question, this needs to be a script that can be rolled out to new machines - which UUID entry is the one I want for e.g. IPv4 network booting?

1 Answers1

0

OK, I figured it out: bcdedit /enum firmware will print the description and id for all UEFI boot manager entries.

With the help of this: https://stackoverflow.com/questions/78076491/create-an-array-from-bcdedit-firmware-output

I was able to create a script setting the first preferred boot entry according to string matches on its description, like so (PowerShell):

function FWList {
    $FWStore = bcdedit /enum firmware
    $FWOS = ($FWStore | select-string Bezeichner,device,path,description) -notmatch '{fwbootmgr}'
    for ( $n=0; $n -lt $FWOS.count; $n++ ) {
        if ( $FWOS[$n] -match 'Bezeichner' ) {
            if ( $FWOS[$($n + 1 )] -match 'device' ) {
                [PsCustomObject]@{
                    des  = $FWOS[$($n + 3)].line.TrimStart('description').Trim()
                    id   = $FWOS[$n].line.Split()[-1]
                    path = $FWOS[$($n + 2)].line.Split()[-1]
                    dev  = $FWOS[$($n + 1)].line.Split()[-1]
                }
            } else {
            [PsCustomObject]@{
                    des  = $FWOS[$($n + 1)].line.TrimStart('description').Trim()
                    id   = $FWOS[$n].line.Split()[-1]
                }
            }
        }
    }
}

(FWList) | ForEach-Object { # Fujitsu D3220-B1 if ($.des.StartsWith("UEFI: IP4")) { bcdedit /set '{fwbootmgr}' displayorder $.id /addfirst break } # Lenovo P16v Gen1 21FC if ($.des -eq "PXE BOOT") { bcdedit /set '{fwbootmgr}' displayorder $.id /addfirst break } # QEmu VM if ($.des.StartsWith("UEFI PXEv4")) { bcdedit /set '{fwbootmgr}' displayorder $.id /addfirst break } }

Caution: The Bezeichner is localized in bcdedit's output, for English it would be identifier. Other languages, you will have to figure it out.