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

    Windows delete pxe boot after deploy

    Scheduled Pinned Locked Moved
    General Problems
    2
    5
    670
    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.
    • L
      lebrun78
      last edited by

      Hello,
      In UEFI, Windows clears the PXE entry from the BIOS settings after a deployment.
      What method do you use to keep PXE in UEFI boot options?

      Arnaud

      Fog Version: Fog 1.5.10
      Server OS: AlmaLinux release 8.8

      1 Reply Last reply Reply Quote 0
      • L
        lebrun78
        last edited by

        I found on this forum a solution:
        This powershel script works to set boot on pxe :

        This PowerShell script moves the first non windows entry to the top of the list.
        
        # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
        # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
        # by mmseng
        # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order
        
        # Notes:
        # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
        # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "{bootmgr}" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
        # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
        # - This functionality relies on the completely undocumented feature of bcdedit to modify the "{fwbootmgr}" GPT entry, which contains the overall list of UEFI boot devices.
        # - AFAICT bcdedit is really only designed to edit Windows' own "{bootmgr}" entry which represents one of the "boot devices" in the overall UEFI list.
        # - Here are some sources:
        #   - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
        #   - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
        #   - https://www.boyans.net/DownloadVisualBCD.html
        #   - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
        #   - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows
        
        
        # Read current boot order
        echo "Reading current boot order..."
        $bcdOutput = cmd /c bcdedit /enum "{fwbootmgr}"
        echo $bcdOutput
        
        # Kill as many of the stupid characters as possible
        echo "Removing extraneous characters from boot order output..."
        $bcdOutput = $bcdOutput -replace '\s+',''
        $bcdOutput = $bcdOutput -replace '`t',''
        $bcdOutput = $bcdOutput -replace '`n',''
        $bcdOutput = $bcdOutput -replace '`r',''
        $bcdOutput = $bcdOutput.trim()
        $bcdOutput = $bcdOutput.trimEnd()
        $bcdOutput = $bcdOutput.trimStart()
        $bcdOutput = $bcdOutput -replace ' ',''
        echo $bcdOutput
        
        # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
        # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
        # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
        # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
        # However this seems to work, even though I can't replicate the results in any regex testers
        $regex = [regex]'^{([\-a-z0-9]+)+}'
        echo "Defined regex as: $regex"
        
        # Save matches
        echo "Save strings matching regex..."
        $foundMatches = $bcdOutput -match $regex
        
        # Grab first match
        # If Windows Boot Manager (a.k.a. "{bootmgr}" was the first in the list, this should be the second
        # Which means it was probably the first before Windows hijacked the first spot
        # Which means it was probably my "EFI Network" boot device
        $secondBootEntry = $foundMatches[0]
        echo "First match: $secondBootEntry"
        
        # Move it to the first spot
        echo "Running this command:"
        echo "cmd /c bcdedit $bcdParams /set `"{fwbootmgr}`" displayorder $secondBootEntry /addfirst"
        cmd /c bcdedit $bcdParams /set "{fwbootmgr}" displayorder $secondBootEntry /addfirst
        

        Fog Version: Fog 1.5.10
        Server OS: AlmaLinux release 8.8

        1 Reply Last reply Reply Quote 0
        • S
          Sebastian Roth Moderator
          last edited by

          @lebrun78 You might want to read through this topic as well: https://forums.fogproject.org/topic/16703/dual-boot-2-disks-unable-to-boot-grub

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          L 2 Replies Last reply Reply Quote 0
          • L
            lebrun78 @Sebastian Roth
            last edited by

            This powershell script is better:

            # Create text file containing firmware settings
            bcdedit /enum firmware > c:\temp\firmware.txt
            
            # Find the line containing "IPV4", and read the line just before that
            $FullLine = (( Get-Content c:\temp\firmware.txt | Select-String "IPV4" -Context 1 ).context.precontext)[0]
            
            # Delete our temporary file
            #del firmware.txt
            
            # Split line into fields using the first left-curly as the delimiter,
            # and then grab the second field (and restore the first left-curly)
            $GUID = '{' + $FullLine.split('{')[1]
            
            # Set the boot order
            #bcdedit /set {fwbootmgr} displayorder $GUID {bootmgr}
            cmd /c bcdedit /set "{fwbootmgr}" displayorder $GUID /addfirst
            

            Fog Version: Fog 1.5.10
            Server OS: AlmaLinux release 8.8

            1 Reply Last reply Reply Quote 0
            • L
              lebrun78 @Sebastian Roth
              last edited by lebrun78

              I try to run the script as snapin
              But I get no c:\temp\firmware.txt file
              I think the script is not executed

              Here is the command line viewed on the fog console:
              powershell.exe -ExecutionPolicy RemoteSigned -NoProfile -File boot-uefi.ps1

              I get this log

              ------------------------------------------------------------------------------
               31/03/2023 16:08:35 Client-Info Client Version: 0.11.19
               31/03/2023 16:08:35 Client-Info Client OS:      Windows
               31/03/2023 16:08:35 Client-Info Server Version: 1.5.8
               31/03/2023 16:08:35 Middleware::Response Success
               31/03/2023 16:08:35 SnapinClient Running snapin boot-uefi-pxe-first
               31/03/2023 16:08:35 Middleware::Communication Download: http://148.60.x.x//fog/service/snapins.file.php?mac=B8:85:84:AC:89:FA&taskid=5453
               31/03/2023 16:08:36 SnapinClient C:\Program Files (x86)\FOG\tmp\boot-uefi.ps1
               31/03/2023 16:08:36 Bus Emmiting message on channel: Notification
               31/03/2023 16:08:36 SnapinClient Starting snapin
               31/03/2023 16:08:40 SnapinClient Snapin finished
               31/03/2023 16:08:40 SnapinClient Return Code: 0
               31/03/2023 16:08:40 Bus Emmiting message on channel: Notification
               31/03/2023 16:08:40 Middleware::Communication URL: https://fogus/fog/service/snapins.checkin.php?taskid=5453&exitcode=0&mac=B8:85:84:AC:89:FA&newServ
              

              Any idea ?

              Fog Version: Fog 1.5.10
              Server OS: AlmaLinux release 8.8

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              162

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project