This is a simple Little script used to demonstrate how easy it is to script and play around with advanced feature in the iPXE Anywhere web service.

Basically we have two separate primary servers, but we want to be able to PXE boot from both of them, and choose at deployment time which one to boot from, from the same network. Historic approaches to this is to have different build networks, or VLANs, using the good ol’ method of stopping the WDS server on one site and starting on the other etc. But they are all pretty lame solutions, the network should be able to do better? Enter iPXE Anywhere to the rescue! No more “net stop WDSServer”… I promise!

So the basic setup here is, two separate ConfigMgr Primary sites, not connected. Then each one of the primary sites then have one DP with our 2PXE server installed. Last, we have the iPXE Anywhere web service installed on another server, which both 2PXE servers will talk to.

Both 2PXE Servers are then configured to send the boot request to the iPXE Web Service which will then present a menu, that can be used to select the Primary to boot from. Of course you can make this extremely custom, and advanced, like checking each primary for the MAC and UUID etc and then take different actions, but here we are keeping it simple.

Don’t call me stupid, but we could need a diagram to explain this!

Sure, or just read a little bit more, it will make you smarter. So the process is like this:

  1. Machine PXE boots
  2. A 2PXE Server picks up the boot request, either from DHCP or the built in proxyDHCP via relay, and boots the awesome open source iPXE Network Boot Program
  3. Embedded script in iPXE NBP contacts the 2PXE Server over HTTP
  4. 2PXE Server detects that this is boot request that should be sent to the iPXE Web Service
  5. The iPXE NBP talks to the iPXE Anywhere WS, which presents the menu
  6. User selects in the meny, sending back the request the corresponding 2PXE Server, now with the Override flag
  7. 2PXE receives the HTTP request, and checks ConfigMgr as per the regular boot process
  8. Machine boots WinPE… and the rest is as we call it, history!

Ok enough marketing blurb, where is da cheese?

So this is the .ps1 script snippet that will be called by the iPXE Anywhere Web Service, info after # shows some snippets of info of what’s going on:

#Sample Small Menu Choosing two primary Servers
$BootObject.iPXEScript = @"
# Some menu defaults
set menu-timeout 15000
set submenu-timeout `${menu-timeout}
isset `${menu-default} || set menu-default exit
# Figure out if client is 64-bit capable
cpuid --ext 29 && set arch x64 || set arch x86
cpuid --ext 29 && set archl amd64 || set archl i386
###################### MAIN MENU ####################################
menu iPXE boot menu for iPXE Anywhere
item --gap --             ------------------------- Choose Environment -----------------------------
item --key s school       Boot School Primary
item --key a admin        Boot Admin Primary
item --gap --             ------------------------- Advanced options -------------------------------
item --key c config       Configure settings
item shell                Drop to iPXE shell
item reboot               Reboot computer
item --key x exit         Exit iPXE and continue boot
choose --timeout `${menu-timeout} --default `${menu-default} selected || goto cancel
set menu-timeout 0
goto `${selected}
#We end up here if some exits out of the menu, which drops you to shell
echo You cancelled the menu, dropping you to a shell
echo Type 'exit' to get the back to the menu
set menu-timeout 0
set submenu-timeout 0
goto start
echo Booting failed, dropping to shell
goto shell
goto start
#Update the next-server address, to the IP address of the other 2PXE server you want to boot
set next-server
goto doit
#Update the next-server address, to the IP address of the other 2PXE server you want to boot
set next-server
goto doit
# This is the key, where we instruct the 2PXE Server to override the request to 2PXE! Epic!
param --params bootreq WSOverride 1
#set a variable to hold the URL, using other variables
set bootinfourl http://`${next-server}:`${defaulthttp_port}/2PXE/`${bootprogram}##params=bootreq ||
#Now boot that URL using the CHAIN command
chain -ar `${bootinfourl}
#deal with errors here
#Return the boot object from the iPXE web service
return $BootObject

In case you missed it, there are no pictures or diagram explaining the setup, but please feel free to draw one yourself. 🙂