# Requires running PowerShell as Administrator # GUID for the EFI global variable $EFI_GLOBAL_GUID = "{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}" # Define the GetFirmwareEnvironmentVariable function $GetFirmwareEnvironmentVariable = @" using System; using System.Runtime.InteropServices; public class UEFI { [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] public static extern uint GetFirmwareEnvironmentVariable( string lpName, string lpGuid, byte[] pBuffer, uint nSize ); } "@ Add-Type -TypeDefinition $GetFirmwareEnvironmentVariable # Function to read a boot entry function Read-BootEntry { param([string]$BootEntryID) $buffer = New-Object byte[] 4096 # Adjust size if needed $size = [UEFI]::GetFirmwareEnvironmentVariable("Boot$BootEntryID", $EFI_GLOBAL_GUID, $buffer, $buffer.Length) if ($size -ne 0) { $data = $buffer[0..($size - 1)] [string]::Join("", ($data | ForEach-Object { "{0:X2}" -f $_ })) } else { $null } } # Enumerate boot entries from 0000 to FFFF for ($i = 0; $i -le 0xFFFF; $i++) { $id = "{0:X4}" -f $i $entry = Read-BootEntry $id if ($entry) { Write-Host "Found Boot$id" } } # Note: Parsing the boot entry data to extract the description requires more complex parsing