0

I have a machine with two separate drives, the main drive (call it C:) I am constantly reimaging with different versions of Windows using PowerShell and the other drive (call it D:) I am keeping a static image of Windows 7. Currently I have the main boot drive set as the C: drive and any time I need to boot from the D: drive I manually restart the machine and choose the boot drive from the BIOS menu.

Is there a way that a PowerShell script would be capable of setting which drive to boot from (i.e. change the boot drive from C: to D:)?

  • That depends. There isn't any standard way for software to tell a conventional BIOS which drive to boot from. (Some vendors may provide solutions.) I'm not sure about UEFI, that might be possible. But the Windows boot partition can boot Windows from another drive, and *that's* configurable in software. I'm not sure how well it supports booting to different versions of Windows though. And it would make it harder to recover if the boot process becomes corrupted for any reason, e.g., is configured to only boot an instance of Windows that no longer exists. – Harry Johnston Sep 30 '15 at 22:52

1 Answers1

0

I do not recall seeing a built-in PowerShell cmdlet for it, but it looks like you are asking for some automation around 'bcdedit'.

You would use

bcdedit /enum

to display the existing bootable objects and once you know what you need to set as the new default, then all you have to do is put that into a PowerShell script. The key command for you is

bcdedit /default {NewGUID}

as in

bcdedit /default \{6443870f-3c0c-11dd-845a-c03899eeb4ec\}

This is a good read if you are not familiar with the command: https://msdn.microsoft.com/en-us/library/windows/hardware/ff543428(v=vs.85).aspx

Adil Hindistan
  • 6,351
  • 4
  • 25
  • 28