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:)?
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