Cleaning up Boot Configuration Data store (BCD) using Powershell


You may have the misfortune of running into a situation where disks have been added and/or removed from a server a number of times. If these disks contain the system and/or boot partitions, invalid entries in the BCD store may be left behind. Here’s an example:

Disk1

In this example, if we try to remove the mirror off the missing disk at the bottom:

Disk2

We’ll get the following error:

Disk3

Taking a look at the BCD using the command BCDEDIT /V shows:

Windows Boot Manager
——————–
identifier {9dea862c-5cdd-4e70-acc1-f32b344d4795}
device unknown
description Windows Boot Manager
locale en-US
inherit {7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}
bootshutdowndisabled Yes
default {92a10962-be7e-11e3-8f5b-f7f89b276248}
resumeobject {92a10961-be7e-11e3-8f5b-f7f89b276248}
displayorder {92a10962-be7e-11e3-8f5b-f7f89b276248}
{92a10969-be7e-11e3-8f5b-f7f89b276248}
{92a1096e-be7e-11e3-8f5b-f7f89b276248}
toolsdisplayorder {b2721d73-1db4-4c62-bf78-c548a880142d}
timeout 30

Windows Boot Loader
——————-
identifier {92a10962-be7e-11e3-8f5b-f7f89b276248}
device unknown
path \Windows\system32\winload.exe
description Windows Server 2012 R2
locale en-US
inherit {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {92a10963-be7e-11e3-8f5b-f7f89b276248}
recoveryenabled Yes
allowedinmemorysettings 0x15000075
osdevice unknown
systemroot \Windows
resumeobject {92a10961-be7e-11e3-8f5b-f7f89b276248}
nx OptOut
hypervisorlaunchtype Auto
ems Yes

Windows Boot Loader
——————-
identifier {92a10969-be7e-11e3-8f5b-f7f89b276248}
device unknown
path \Windows\system32\winload.exe
description Windows Server 2012 R2 – secondary plex
locale en-US
inherit {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {92a10963-be7e-11e3-8f5b-f7f89b276248}
recoveryenabled Yes
allowedinmemorysettings 0x15000075
osdevice unknown
systemroot \Windows
resumeobject {92a10961-be7e-11e3-8f5b-f7f89b276248}
nx OptOut
ems Yes

Windows Boot Loader
——————-
identifier {92a1096e-be7e-11e3-8f5b-f7f89b276248}
device partition=C:
path \Windows\system32\winload.exe
description Windows Server 2012 R2 – secondary plex
locale en-US
inherit {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {92a10963-be7e-11e3-8f5b-f7f89b276248}
recoveryenabled Yes
allowedinmemorysettings 0x15000075
osdevice partition=C:
systemroot \Windows
resumeobject {92a10961-be7e-11e3-8f5b-f7f89b276248}
nx OptOut
hypervisorlaunchtype Auto
ems Yes

Notice the entries showing  device unknown. These are entries that belong to disks that are no longer physically present in this server, and need to be deleted.  The following script does just that:

Disk4

The script can be downloaded from the Microsoft Script Center Repository.

After running the script, reboot the server. Going back into Computer Management, you now can remove the mirror off the missing disk.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s