none
Multiple entries of "Windows Boot manager" in UEFI on Surface Pro 3 RRS feed

  • Question

  • Hi 

    We are deploying a custom captured image on  Surface Pro 3 using a  using MDT 2013. 
    Every time i deploy a image there is a new "Windows Boot Manager" entry created and same is visible when you try to boot from a device. 

    The below post talks about the same issue but option given is to use bcdedit
    http://www.windows-noob.com/forums/index.php?/topic/7817-multiple-windows-boot-manager-entries-under-uefi-section/

    The below post says that Dell would be fixing it in future BIOS releases. 
    http://social.technet.microsoft.com/Forums/en-US/192596f1-1c68-4c4b-8b0f-21b279a79403/eufi-options-multiple-windows-boot-manager-entries?forum=mdt

    Is it a bug with the surface pro 3 UEFI or am i doing something wrong? 
    We are using the same image to deploy ON Lenovo Thinkpad 10 but i dont see this issue.

    BCDEdit /deletevalue might be an option but want to know if it is a known bug or something wrong with the way i am doing.

    UK


    Monday, September 8, 2014 3:48 AM

Answers

All replies

  • Hi 

    We are deploying a custom captured image on  Surface Pro 3 using a  using MDT 2013. 
    Every time i deploy a image there is a new "Windows Boot Manager" entry created and same is visible when you try to boot from a device. 

    The below post talks about the same issue but option given is to use bcdedit
    http://www.windows-noob.com/forums/index.php?/topic/7817-multiple-windows-boot-manager-entries-under-uefi-section/

    The below post says that Dell would be fixing it in future BIOS releases. 
    http://social.technet.microsoft.com/Forums/en-US/192596f1-1c68-4c4b-8b0f-21b279a79403/eufi-options-multiple-windows-boot-manager-entries?forum=mdt

    Is it a bug with the surface pro 3 UEFI or am i doing something wrong? 
    We are using the same image to deploy ON Lenovo Thinkpad 10 but i dont see this issue.

    BCDEdit /deletevalue might be an option but want to know if it is a known bug or something wrong with the way i am doing.

    UK


    I am experiencing the same issue with some Lenovo laptops we are using to test SCCM/MDT deployments of Windows 8.1 with UEFI enabled. I believe this is an issue with UEFI in general. I found some more information here:

    http://jeff.squarecontrol.com/archives/184

    If that's the case with UEFI, I think we're going to have to create a script that deletes duplicate firmware objects during an OSD task sequence. 

    EDIT: By the way, this technet article seems to concur with the above link. It seems on "some" UEFI systems this can happen: http://technet.microsoft.com/en-us/library/cc749510(v=ws.10).aspx
    • Edited by Yabos Tuesday, September 23, 2014 1:06 PM Added info
    • Proposed as answer by Yabos Tuesday, September 23, 2014 1:06 PM
    Monday, September 22, 2014 7:04 PM
  • Hello,

    I am seeing this same behaviour when reimaging a Lenovo Helix with UEFI. Did you get around to creating a script from the above Blog Post? I am not sure how the script could work dynamically as the multiple IDs will not be known instantly.

    Any thoughts appreciated


    Lee Bowman MCITP MCTS

    Monday, October 13, 2014 2:33 PM
  • Hello,

    I am seeing this same behaviour when reimaging a Lenovo Helix with UEFI. Did you get around to creating a script from the above Blog Post? I am not sure how the script could work dynamically as the multiple IDs will not be known instantly.

    Any thoughts appreciated


    Lee Bowman MCITP MCTS

    I've temporarily taken a break from trying. I used the script from the link I gave above, couldn't get it working, and was unable to get any help on the Technet forums https://social.technet.microsoft.com/Forums/scriptcenter/en-US/b81c6701-ee27-429e-a25b-d9028f30a52e/vbs-having-issues-trying-to-delete-duplicate-uefi-firmware-objects-in-bcmnvram?forum=ITCG

    I hope to come back to it at some point. I'll likely have to start one from scratch as I'm not making any sense of the script posted. If you find a solution I'd appreciate a heads-up, I'll do the same if I find one as well. Thanks. 

    Monday, October 13, 2014 3:35 PM
  • What is the fix for this?  I'm having the same issue in another UEFI laptop.  

    I looked at the Microsoft link and it does not work for me because the Windows bcdedit command output does not see the entries.  I see 21 "Windows Boot Manager" entries in the BIOS.  A new one is created every time the system is reimaged and I can't find any way to get rid of it.

    The system now stops booting from external hard drives because it must have hit a limit.



    • Edited by MyGposts Sunday, January 4, 2015 12:01 AM
    Saturday, January 3, 2015 11:59 PM
  • Tuesday, January 6, 2015 12:03 AM
    Moderator
  • I was actually looking for a automated way to delete the orphan entries so that we can add a script in MDT to delete these entries at the end of the Task sequence. 

    I currently do not have a Surface Pro with me but wrote a script to convert the bcdedit output to a powershell object. Once i have the tablet i will check if this can be automated.

    Below is the script

    # Function to convert the output of bcdedit command to a powershell object
    Function Get-BCDObject() {
        $bcdEntries = bcdedit /enum firmware
        $bcdObject = @() 
    
        foreach($bcdEntry in $bcdEntries) {
            
            if ($bcdEntry -eq "Windows Boot Loader" -or $bcdEntry -eq "Windows Boot Manager" -or ($bcdEntry -eq "") -or $bcdEntry.Contains("-----")) {
                if ($bcdEntry.Contains("-----")){
                    $object1 = New-Object PSObject
                    $bcdObject += $object1
                }
            }
            else {
                $bcdsplit = $bcdEntry.Split(" ")
                $property = $bcdsplit[0]
                $value = ($bcdEntry.Substring($bcdsplit[0].length)).trim()
                        
                $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value 
            }
        }
        return $bcdObject
    }
    
    $bcdObjs = Get-BCDObject # Store bcdedit output in a Powershell object
    
    foreach ($bcdObj in $bcdObjs) {
        # Can we have a logic to loop through the object and delete the orphan entries?
    }
    

    Saturday, January 24, 2015 6:47 AM
  • I was actually looking for a automated way to delete the orphan entries so that we can add a script in MDT to delete these entries at the end of the Task sequence. 

    I currently do not have a Surface Pro with me but wrote a script to convert the bcdedit output to a powershell object. Once i have the tablet i will check if this can be automated.

    Below is the script

    # Function to convert the output of bcdedit command to a powershell object
    Function Get-BCDObject() {
        $bcdEntries = bcdedit /enum firmware
        $bcdObject = @() 
    
        foreach($bcdEntry in $bcdEntries) {
            
            if ($bcdEntry -eq "Windows Boot Loader" -or $bcdEntry -eq "Windows Boot Manager" -or ($bcdEntry -eq "") -or $bcdEntry.Contains("-----")) {
                if ($bcdEntry.Contains("-----")){
                    $object1 = New-Object PSObject
                    $bcdObject += $object1
                }
            }
            else {
                $bcdsplit = $bcdEntry.Split(" ")
                $property = $bcdsplit[0]
                $value = ($bcdEntry.Substring($bcdsplit[0].length)).trim()
                        
                $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value 
            }
        }
        return $bcdObject
    }
    
    $bcdObjs = Get-BCDObject # Store bcdedit output in a Powershell object
    
    foreach ($bcdObj in $bcdObjs) {
        # Can we have a logic to loop through the object and delete the orphan entries?
    }

    Any update to this?

    There's no place like 127.0.0.1

    Monday, November 16, 2015 7:02 PM
  • I wrote an update to this script which deletes all UEFI boot managers except for the current active one. It's 'cheap and nasty' but it works...

    See below:

    Function Get-BCDObject()
    {
    	$bcdEntries = bcdedit /enum firmware
    	$bcdObject = @()
    	
    	foreach ($bcdEntry in $bcdEntries)
    	{
    		
    		if ($bcdEntry -eq "Windows Boot Loader" -or $bcdEntry -eq "Windows Boot Manager" -or ($bcdEntry -eq "") -or $bcdEntry.Contains("-----"))
    		{
    			if ($bcdEntry.Contains("-----"))
    			{
    				$object1 = New-Object PSObject
    				$bcdObject += $object1
    			}
    		}
    		else
    		{
    			$bcdsplit = $bcdEntry.Split(" ")
    			$property = $bcdsplit[0]
    			$value = ($bcdEntry.Substring($bcdsplit[0].length)).trim()
    			
    			$object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    		}
    	}
    	return $bcdObject
    }
    
    $bcdObjs = Get-BCDObject # Store bcdedit output in a Powershell object
    
    foreach ($bcdObj in $bcdObjs)
    {
    	$BootIdentifier = $bcdObj.identifier
    	$BootDescription = $bcdObj.description
    	If ($BootDescription -eq "Windows Boot Loader" -or $BootDescription -eq "Windows Boot Manager" -and $BootIdentifier -ne "{bootmgr}")
    	{
    		bcdedit /delete $BootIdentifier /cleanup /f
    	}
    }

    If you'd like to include the current boot manager just remove the -and $BootIdentifier -ne "{bootmgr}" component towards the bottom.


    MrGoodBytes

    • Proposed as answer by MrGoodBytes Thursday, September 15, 2016 1:57 AM
    Thursday, September 15, 2016 1:55 AM
  • I wrote an update to this script which deletes all UEFI boot managers except for the current active one. It's 'cheap and nasty' but it works...

    Awesome, nice work! ;)

    There's no place like 127.0.0.1

    Thursday, September 15, 2016 3:47 PM
  • Have you every come across a solution on this when there are not entries to delete using bcdedit? On my systems that I re-image multiple times using MDT, these Windows Boot Manager appear in UEFI even though the disk is wiped. The only way to remove them is to do it from the System Setup.
    Wednesday, October 12, 2016 5:47 PM
  • @peopleman1 Did you find a solution?

    MrGoodBytes

    Tuesday, February 21, 2017 4:22 AM
  • Using diskpart to clean the drive or delete the partitions should clear out all those Boot Manager entries. Do it before you reimage the machine, of course this will wipe out any data on the drive.
    Tuesday, February 21, 2017 2:12 PM
  • How long, I wonder, before this is finally integrated into the MDT / DISM process?

    There's no place like 127.0.0.1

    Tuesday, February 21, 2017 5:14 PM
  • I wrote an update to this script which deletes all UEFI boot managers except for the current active one. It's 'cheap and nasty' but it works...

    See below:

    Function Get-BCDObject()
    {
    	$bcdEntries = bcdedit /enum firmware
    	$bcdObject = @()
    	
    	foreach ($bcdEntry in $bcdEntries)
    	{
    		
    		if ($bcdEntry -eq "Windows Boot Loader" -or $bcdEntry -eq "Windows Boot Manager" -or ($bcdEntry -eq "") -or $bcdEntry.Contains("-----"))
    		{
    			if ($bcdEntry.Contains("-----"))
    			{
    				$object1 = New-Object PSObject
    				$bcdObject += $object1
    			}
    		}
    		else
    		{
    			$bcdsplit = $bcdEntry.Split(" ")
    			$property = $bcdsplit[0]
    			$value = ($bcdEntry.Substring($bcdsplit[0].length)).trim()
    			
    			$object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    		}
    	}
    	return $bcdObject
    }
    
    $bcdObjs = Get-BCDObject # Store bcdedit output in a Powershell object
    
    foreach ($bcdObj in $bcdObjs)
    {
    	$BootIdentifier = $bcdObj.identifier
    	$BootDescription = $bcdObj.description
    	If ($BootDescription -eq "Windows Boot Loader" -or $BootDescription -eq "Windows Boot Manager" -and $BootIdentifier -ne "{bootmgr}")
    	{
    		bcdedit /delete $BootIdentifier /cleanup /f
    	}
    }

    If you'd like to include the current boot manager just remove the -and $BootIdentifier -ne "{bootmgr}" component towards the bottom.


    MrGoodBytes

    At what point in your Task Sequence are you running this?

    Thanks!

    -Matt


    There's no place like 127.0.0.1

    Monday, March 20, 2017 9:43 PM
  • We've included it as a post install task after the Setup Windows and ConfigMgr step. No specific reason for that, it just seemed like the most fitting. The script can be run at any point in the task sequence including from within WinPE.

    If you do run it before you install Windows I'd recommend you also remove the current boot manager else you'll have two entries after Windows does eventually install.


    MrGoodBytes

    Tuesday, March 21, 2017 10:36 AM
  • We've included it as a post install task after the Setup Windows and ConfigMgr step. No specific reason for that, it just seemed like the most fitting. The script can be run at any point in the task sequence including from within WinPE.

    If you do run it before you install Windows I'd recommend you also remove the current boot manager else you'll have two entries after Windows does eventually install.


    MrGoodBytes

    I tried running it, modified to remove ALL entries, in several places before the Install step with no luck.  This seemed to me like the ideal way to do it at the time.

    I then moved it to the State Restore section, allowing it to preserve the current entry, and it seems to work fine (Only the one entry remaining).  I do need to go back and suppress the error messages being generated, because the LiteTouch summary includes warnings from this scripts output.

    I don't usually do this, but for now I've just added a global error suppression to the script.

    $ErrorActionPreference = "SilentlyContinue"


    PowerShell version detected: 5.0.10586.672 ZTIPowerShell 3/20/2017 6:50:53 PM 0 (0x0000) About to run: "C:\MININT\Modules\Microsoft.BDD.TaskSequenceModule\Microsoft.BDD.TaskSequencePSHost40.exe" "\\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1" "C:\MININT\SMSOSD\OSDLOGS" ZTIPowerShell 3/20/2017 6:50:53 PM 0 (0x0000) Cannot bind argument to parameter 'InputObject' because it is null. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:15 + ... $object1 | Add-Member -MemberType NoteProperty -Name $($property) -V ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) Cannot bind argument to parameter 'Name' because it is an empty string. TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) At \\MDTMASTER.domain.com\DeploymentShare$\Scripts\BCDEditUEFI.ps1:29 char:57 + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value ... + ~~~~~~~~~~~~ TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) InvalidData: (:) [Add-Member], ParameterBindingValidationException TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) TSHOST: Script completed with return code 0 TaskSequencePSHost 3/20/2017 6:50:57 PM 0 (0x0000) ZTIPowerShell processing completed successfully. ZTIPowerShell 3/20/2017 6:50:57 PM 0 (0x0000) Event 41001 sent: ZTIPowerShell processing completed successfully. ZTIPowerShell 3/20/2017 6:50:58 PM 0 (0x0000)


    There's no place like 127.0.0.1


    • Edited by Matt5150 Tuesday, March 21, 2017 3:49 PM
    Tuesday, March 21, 2017 3:26 PM
  • Looks like the Get-BCDObject function is failing or returning no results. That's very interesting. I've had it throw any errors nor had to specify to silently continue with this script before. At most I only bypass the execution policy.

    First thing I'd suggest is to check whether "bcdedit /enum firmware" is returning anything.

    If you add any error handling to the script be sure to share it :)


    MrGoodBytes

    Friday, March 24, 2017 5:55 AM
  • Looks like the Get-BCDObject function is failing or returning no results. That's very interesting. I've had it throw any errors nor had to specify to silently continue with this script before. At most I only bypass the execution policy.

    First thing I'd suggest is to check whether "bcdedit /enum firmware" is returning anything.

    If you add any error handling to the script be sure to share it :)


    MrGoodBytes

    It does.  Some of the machines I was running it on had an F12 boot menu that ran off the screen. :D

    While testing this script I was running BCDEDIT /enum, before and after, to check that it worked.  Not all of the results from the script are errors, but there are always at least 4 of them.  This is being used on Surface devices, and Dell computers, if that makes any difference.

    -Matt


    There's no place like 127.0.0.1

    Friday, March 24, 2017 4:48 PM
  • when I run this I get this error:

    Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
    At C:\Users\tester\Desktop\UEFIRemoveWBM.ps1:23 char:15
    + ...  $object1 | Add-Member -MemberType NoteProperty -Name $($property) -V ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCo
       mmand

    Add-Member : Cannot bind argument to parameter 'Name' because it is an empty string.
    At C:\Users\tester\Desktop\UEFIRemoveWBM.ps1:23 char:57
    + ... ect1 | Add-Member -MemberType NoteProperty -Name $($property) -Value  ...
    +                                                      ~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.AddM
       emberCommand

    Update:

    Found that a blank(null) was being returned from $bcdEntry into $property so I just had the script check for this:

    if ($property -notlike "")
    {
    $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    }

    • Edited by PeteBC Thursday, May 4, 2017 3:24 PM
    Thursday, May 4, 2017 1:56 PM
  • Update:

    Found that a blank(null) was being returned from $bcdEntry into $property so I just had the script check for this:

    if ($property -notlike "")
    {
    $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    }

    Good work!

    I've included that in my copy and stuck it in the Script Center repo for convenience.

    https://gallery.technet.microsoft.com/scriptcenter/Clear-Windows-Boot-Manager-7020323d


    MrGoodBytes

    Friday, May 5, 2017 8:10 AM
  • Update:

    Found that a blank(null) was being returned from $bcdEntry into $property so I just had the script check for this:

    if ($property -notlike "")
    {
    $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    }

    Good work!

    I've included that in my copy and stuck it in the Script Center repo for convenience.

    https://gallery.technet.microsoft.com/scriptcenter/Clear-Windows-Boot-Manager-7020323d


    MrGoodBytes

    Not so fast. So I am still getting this error at least during one of the loop throughs. For some reason its thinking the $property is not a null or empty or while space but when it goes to add one of properties to $object is says its equal to null and cant bind

    I've changed the code try to ferret this out but its still erroring on me:

    IF([string]::IsNullOrEmpty($property)) {}
    else
    {
    IF([string]::IsNullOrwhiteSpace($property)) {}else

    {
    $object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    }

    error: Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.

    Its definitely something to do with what data its bringing in from the bcdedit /enum firmware

    If I use just  bcdedit /enum it does not error out but also does not delete the extra windows boot manager


    • Edited by PeteBC Friday, May 5, 2017 3:24 PM
    Friday, May 5, 2017 3:19 PM
  • OK guys, I finally figured out how to get rid of the "null" error. Blame on the "Firmware Boot Manager" and its "display order" property containing multiple entries.

    I added a fix to the script to skip the whole Firmware Boot Manager part, I also added a fix for french language, you can adapt it to any language.

    I tried to use regex to remove the Firmware Boot manager but my command did not work, I don't know why, so I used a variable to skip this part.

    # ---------------------------------------------------------------------------
    # Get-LogDir:  Return the location for logs and output files
    # ---------------------------------------------------------------------------
    
    function Get-LogDir
    {
      try
      {
        $ts = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
        if ($ts.Value("LogPath") -ne "")
        {
          $logDir = $ts.Value("LogPath")
        }
        else
        {
          $logDir = $ts.Value("_SMSTSLogPath")
        }
      }
      catch
      {
        $logDir = $env:TEMP
      }
      return $logDir
    }
    
    Function Get-BCDObject()
    {
    	$bcdEntries = bcdedit /enum firmware | Where { $_ -ne "" }
    	$bcdObject = @()
    	
    	$Firmware = $False
    	
    	foreach ($bcdEntry in $bcdEntries)
    	{
    		If ($bcdEntry -eq "Firmware Boot Manager")
    		{
    			$Firmware = $true
    		}
    		Elseif ($bcdEntry -eq "Windows Boot Loader" -or $bcdEntry -eq "Windows Boot Manager" -or ($bcdEntry -eq "") -or $bcdEntry.Contains("-----"))
    		{
    			If (!($bcdEntry.Contains("-----")))
    			{
    				$Firmware = $false
    			}
    			Else
    			{
    				If ($Firmware -eq $true)
    				{
    					Write-Information ''
    					Write-Information "Skipping PSobject creation because '$bcdEntry' is part of 'Firmware Boot Manager'"
    				}
    				Else
    				{
    					Write-Information ''
    					Write-Information "'$bcdEntry' encountered, creating PSobject"
    					$object1 = New-Object PSObject
    					$bcdObject += $object1
    				}
    			}
    		}
    		Else
    		{
    			If ($Firmware -eq $false)
    			{
    				$bcdsplit = $bcdEntry.Split(" ")
    				$property = $bcdsplit[0]
    				$value = ($bcdEntry.Substring($bcdsplit[0].length)).trim()
    				
    				#If ($property -ne '' -or $property -ne ' ' -or $property -ne $null)
    				If ($property -ne '')
    				{
    					If (!($object1))
    					{
    						Write-Information "PSObject does not exist, skipping '$property'."
    					}
    					Else
    					{
    						Write-Information "Adding '$property' to list"
    						$object1 | Add-Member -MemberType NoteProperty -Name $($property) -Value $value
    					}
    				}
    			}
    		}
    	}
    	return $bcdObject
    }
    
    $logDir = Get-LogDir
    Start-Transcript "$logDir\Remove-OldBCDEntries.log"
    
    $bcdEntriesBefore = bcdedit /enum firmware
    Write-Information 'BCDEdit before:'
    ForEach ($bcdEntryBefore in $bcdEntriesBefore)
    {
     Write-Information "$($bcdEntryBefore)"
    }
    Write-Information 'End BCDEdit before'
    Write-Information ''
    
    If (Test-Path -Path "HKLM:\SYSTEM\ControlSet001\Control\MiniNT" -PathType Container)
    {
    	Write-Information "Running in WinPE."
    	Write-Information ''
    	$script:Offline = $true
    }
    Else
    {
    	Write-Information "Running in Full OS."
    	Write-Information ''
    	$script:Offline = $false
    }
    
    # Store bcdedit output in a Powershell object
    $bcdObjs = Get-BCDObject
    
    foreach ($bcdObj in $bcdObjs)
    {
    	If ((get-culture).name -eq 'fr-FR')
    	{
    		$BootIdentifier = $bcdObj.identificateur
    	}
    	Else
    	{
    		$BootIdentifier = $bcdObj.identifier
    	}
    
    	$BootDescription = $bcdObj.description
        If ($script:Offline)
    	{
      	If ($BootDescription -eq "Windows Boot Loader" -or $BootDescription -eq "Windows Boot Manager")
    		{
    		Write-Information "Deleting '$BootIdentifier'"
    		bcdedit /delete "$BootIdentifier" /cleanup /f
    		}
    	Else
    		{
    		Write-Information "Skipping '$BootIdentifier'"
    		}
    	}
        Else
    	{
        If ($BootDescription -eq "Windows Boot Loader" -or $BootDescription -eq "Windows Boot Manager" -and $BootIdentifier -ne "{bootmgr}")
    		{
    		Write-Information "Deleting '$BootIdentifier'"
    		bcdedit /delete "$BootIdentifier" /cleanup /f
    		}
    	Else
    		{
    		Write-Information "Skipping '$BootIdentifier'"
    		}
    	}
    }
    $bcdEntriesAfter = bcdedit /enum firmware
    Write-Information 'BCDEdit after:'
    ForEach ($bcdEntryAfter in $bcdEntriesAfter)
    {
     Write-Information "$($bcdEntryAfter)"
    }
    
    Stop-Transcript

    Be careful: offline, this script will remove your current boot loader. I use it as a task I put in MDT before formating. MrGoodBytes don't hesitate to add those lines to the Technet Gallery.

    Hope this helps



    Viadeo: Mathieu Ait Azzouzene | Linkedin: Mathieu Ait Azzouzene


    Saturday, May 13, 2017 8:43 PM
  • Can you show me the particular Task in your Task Sequence where you run this script?

    Thanks!

    Wednesday, June 21, 2017 7:36 PM

  • There's no place like 127.0.0.1

    Wednesday, June 21, 2017 7:41 PM
  • I'm using ConfigMgr so would I just create a Package with:

    powershell.exe -ExecutionPolicy Bypass -File BCDEditUEFI.ps1


    Wednesday, June 21, 2017 7:45 PM
  • I usually run this script just before the format and partition task.

    Viadeo: Mathieu Ait Azzouzene | Linkedin: Mathieu Ait Azzouzene

    Thursday, June 22, 2017 8:04 AM
  • I usually run this script just before the format and partition task.

    Viadeo: Mathieu Ait Azzouzene | Linkedin: Mathieu Ait Azzouzene

    My screenshot says it's running the version of the script to delete ALL entries, but it's not.   I forgot to change the naming when I moved it from Pre-Install to State Restore.

    See my post above as to why I moved it.


    There's no place like 127.0.0.1

    Thursday, June 22, 2017 8:54 PM
  • >See my post above as to why I moved it.

    Your post does not seem to mention why you do not have this in Pre-Install section of the MDT.

    Its working good for me in pre-install before formatting and partitioning the disk. Is there something I'm missing?


    • Edited by PeteBC Wednesday, June 28, 2017 2:00 PM
    Wednesday, June 28, 2017 1:59 PM
  • Your procedure worked for me. I just had to add quotes around the ID:

    C:\> BCDEDIT /D "{599bd3e1-29c1-11e4-b698-3c970e790513}"
    Tuesday, November 14, 2017 4:02 PM