PowerShell: Check if System Uses UEFI or Legacy BIOS
Need to know whether a machine boots via UEFI or the older Legacy BIOS mode - for compatibility checks, dual-boot setups, or troubleshooting a boot issue? This one-liner reads it straight from an environment variable.
Prerequisites:
- Privileges: None
- Module: Built-in, no import needed
Quick Command:
$env:firmware_type
Example Output:
UEFI
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
How It Works:
- $env:firmware_type reads a built-in Windows environment variable that Windows itself sets based on how the system booted - it's not a CIM/WMI query, just a direct read of system state.
- The value returned is either UEFI or Legacy (sometimes seen as BIOS), telling you exactly which firmware mode the machine is currently running in.
- This is simpler and faster than digging through Win32_BIOS, since that CIM class doesn't actually expose this information directly.