Windows 10, UEFI and PXE booting

I recently set up System Centre Configuration Manager to take over from MDT for imaging PCs. The end result I’m after is that all PCs attempt PXE boot when powered up, and then automatically image if there’s a task deployment waiting for them. (Bonus points is getting wake-on-lan to work with Win 10 so they’ll power themselves up too).

Thought this would be easy – surely just set network as the first boot device – only to discover that part of Windows setup adds “Windows Boot Manager” and sets it as the first device in the boot list, no way to stop it.

I’ve come up with a powershell script which uses bcdedit to mess with the boot order – first it looks for an entry containing “IP4”, grabs its ID then sets this as the default. For some reason just being default doesn’t mean it’s the first in the list – so it then changes the boot order to network followed by Boot Manager.

Popped this in near the end of the task sequence and you get deployed PCs which are still set to PXE boot. The fact that there’s a previous image deployment tagged on the computer in SCCM prevents it from getting stuck in a network boot and re-image infinite loop. You can then cause it to image by hitting “Clear required PXE deployment” on the device (or device collection) within SCCM.

$bootEntries = bcdedit /enum all | Select-String "description" -Context 1,0
foreach ($bootEntry in $bootEntries) {
    if ($bootEntry -clike '*IP4*') {
        $boot = $bootEntry.ToString().Split('{')
        $GUID = $boot[1].Split('}')[0]
        bcdedit /default "{$GUID}"
        bcdedit /set "{fwbootmgr}" DISPLAYORDER "{default}" "{bootmgr}"
    }
}

Note I use this with a task sequence which is set as a required deployment. I’ve only tested this on a couple of PCs (one with an Asus board and one with MSI) so I’m assuming that the UEFI IPv4 boot entry is always called something containing “IP4” and not anything different like “IPv4” or “IP 4”