From ec7d84b0e0d7b31006077b9f3739e6c28e9e293a Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 19 Feb 2025 09:14:50 +0100 Subject: [PATCH] Added reboot-into-bios.ps1 --- scripts/reboot-into-bios.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/reboot-into-bios.ps1 diff --git a/scripts/reboot-into-bios.ps1 b/scripts/reboot-into-bios.ps1 new file mode 100644 index 00000000..b12eb39e --- /dev/null +++ b/scripts/reboot-into-bios.ps1 @@ -0,0 +1,25 @@ +# Requires admin privileges to run +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Host "This script requires administrative privileges." -ForegroundColor Red + Write-Host "Please run PowerShell as Administrator and try again." -ForegroundColor Yellow + pause + exit 1 +} + +try { + Write-Host "Preparing to reboot into BIOS/UEFI..." -foregroundColor Yellow + + # Get boot configuration + $bootConfig = bcdedit /enum firmware + if ($lastExitCode -ne 0) { throw "Failed to get boot configuration" } + + # Set the one-time boot to UEFI + $result = shutdown /r /fw /t 0 + if ($lastExitCode -ne 0) { throw "Failed to initiate reboot" } + +} catch { + Write-Host "Error: $_" -ForegroundColor Red + Write-Host "Failed to initiate BIOS reboot." -ForegroundColor Red + pause + exit 1 +} \ No newline at end of file