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:

    1. In FOG Settings > iPXE > Set UEFI exit type to Refind
    2. Edit /var/www/fog/service/ipxe/refind.conf and change the scanfor line to just: scanfor internal - eg remove hdbios


  • This is really great. Thanks for your work :)



  • @netbootdisk This is awesome! Thank you! I’ll get it into the #wiki


 

484
Online

5.4k
Users

12.6k
Topics

118.9k
Posts