• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    PowerShell Code for UEFI DHCP Setup

    Scheduled Pinned Locked Moved
    Tutorials
    3
    4
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • netbootdiskN
      netbootdisk
      last edited by netbootdisk

      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
      Wayne WorkmanW 1 Reply Last reply Reply Quote 5
      • Wayne WorkmanW
        Wayne Workman @netbootdisk
        last edited by

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

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
        Daily Clean Installation Results:
        https://fogtesting.fogproject.us/
        FOG Reporting:
        https://fog-external-reporting-results.fogproject.us/

        1 Reply Last reply Reply Quote 0
        • T
          Taspharel
          last edited by

          This is really great. Thanks for your work 🙂

          1 Reply Last reply Reply Quote 0
          • netbootdiskN
            netbootdisk
            last edited by netbootdisk

            Hi Guys

            Two quick updates on this:

            1. This ipxe7156.ipxe also seems to be working for some Dell machines we have.

            2. 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
            
            1 Reply Last reply Reply Quote 2
            • 1 / 1
            • First post
              Last post

            201

            Online

            12.0k

            Users

            17.3k

            Topics

            155.2k

            Posts
            Copyright © 2012-2024 FOG Project