PowerShell Code for UEFI DHCP Setup
-
The Wiki’s info on UEFI setup is great, but fiddly to setup on lots of Windows Servers, so I’ve converted it to PowerShell.
Suggestions/corrections welcome - the architecture selection is somewhat hard to test with limited devices.
Hope this helps others!
import-module dhcpserver $DHCPserv = "DHCP-SERVER-HOSTNAME" Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 2" -Type Vendor -data 0x505845436c69656e743a417263683a3030303032 -Description "UEFI Architecture Type 2" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 6" -Type Vendor -data 0x505845436c69656e743a417263683a3030303036 -Description "UEFI Architecture Type 6" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 9" -Type Vendor -data 0x505845436c69656e743a417263683a3030303039 -Description "UEFI Architecture Type 9" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 7" -Type Vendor -data 0x505845436c69656e743a417263683a3030303037 -Description "UEFI Architecture Type 7" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 7 UNDI 3016" -Type Vendor -data 0x505845436c69656e743a417263683a30303030373a554e44493a303033303136 -Description "UEFI Architecture Type 7 UNDI 3016 (Surface Pro 4)" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE" -Description "UEFI IPXE" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 7*","PXEClient (UEFI x64) 9*" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE32" -Description "UEFI IPXE32" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 2*","PXEClient (UEFI x64) 6*" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE7156" -Description "UEFI IPXE7156" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 7 UNDI 3016*" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE" -OptionId 67 -Value "ipxe.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE32" -OptionId 67 -Value "i386-efi/ipxe.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE7156" -OptionId 67 -Value "ipxe7156.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -OptionId 67 -Value "undionly.kpxe" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -OptionId 66 -Value "10.20.30.40" -ComputerName $DHCPserv
Also, for those trying to get UEFI working correctly, I had to also do the following:
- In FOG Settings > iPXE > Set UEFI exit type to Refind
- Edit /var/www/fog/service/ipxe/refind.conf and change the scanfor line to just: scanfor internal - eg remove hdbios
-
@netbootdisk This is awesome! Thank you! I’ll get it into the #wiki
-
This is really great. Thanks for your work
-
Hi Guys
Two quick updates on this:
-
This ipxe7156.ipxe also seems to be working for some Dell machines we have.
-
To make Hyper-V Generation 2 VM’s to PXE boot UEFI correctly; I had to add a new PXEclient mapping of PXEClient:Arch:00007:UNDI:003000 for the ipxe7156.ipxe boot file. (Secure boot should also be disabled!)
(Tested with FOG 1.5.2)
Revised Powershell Code:
import-module dhcpserver $DHCPserv = "DHCP-SERVER-HOSTNAME" Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 2" -Type Vendor -data 0x505845436c69656e743a417263683a3030303032 -Description "UEFI Architecture Type 2" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 6" -Type Vendor -data 0x505845436c69656e743a417263683a3030303036 -Description "UEFI Architecture Type 6" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 9" -Type Vendor -data 0x505845436c69656e743a417263683a3030303039 -Description "UEFI Architecture Type 9" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 7" -Type Vendor -data 0x505845436c69656e743a417263683a3030303037 -Description "UEFI Architecture Type 7" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 7 UNDI 3016" -Type Vendor -data 0x505845436c69656e743a417263683a30303030373a554e44493a303033303136 -Description "UEFI Architecture Type 7 UNDI 3016 (Surface Pro 4)" -ComputerName $DHCPserv Add-DhcpServerv4Class -Name "PXEClient (UEFI x64) 7 UNDI 3000" -Type Vendor -data 0x505845436c69656e743a417263683a30303030373a554e44493a303033303000 -Description "UEFI Architecture Type 7 UNDI 3000 (Hyper-V)" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE" -Description "UEFI IPXE" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 7*","PXEClient (UEFI x64) 9*" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE32" -Description "UEFI IPXE32" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 2*","PXEClient (UEFI x64) 6*" -ComputerName $DHCPserv Add-DhcpServerv4Policy -Name "UEFI-IPXE7156" -Description "UEFI IPXE7156" -ScopeId 0.0.0.0 -Condition OR -VendorClass EQ, "PXEClient (UEFI x64) 7 UNDI 3016*","PXEClient (UEFI x64) 7 UNDI 3000*" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE" -OptionId 67 -Value "ipxe.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE32" -OptionId 67 -Value "i386-efi/ipxe.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -PolicyName "UEFI-IPXE7156" -OptionId 67 -Value "ipxe7156.efi" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -OptionId 67 -Value "undionly.kpxe" -ComputerName $DHCPserv Set-DhcpServerv4OptionValue -OptionId 66 -Value "10.20.30.40" -ComputerName $DHCPserv
-