< Back
Get-FirmwareType
Post
NAME Get-FirmwareType
SYNOPSIS
This cmdlet determines the underlying system firmware (BIOS) type - either UEFI or Legacy BIOS.
SYNTAX
Get-FirmwareType [[-QueryType] <String>] [<CommonParameters>]
DESCRIPTION
This cmdlet determines the underlying system firmware (BIOS) type - either UEFI or Legacy BIOS.
The function will use one of three methods to determine the firmware type:
The first method relies on the fact that Windows setup detects the firmware type as a part of the Windows
installation
routine and records its findings in the setupact.log file in the \\Windows\\Panther folder. It's a trivial task to
use
Select-String to extract the relevant line from this file and to pick off the (U)EFI or BIOS keyword it contains.
To do a proper job there are two choices; both involve using Win32 APIs which we call from PowerShell through a
compiled
(Add-Type) class using P/Invoke.
For Windows 7/Server 2008R2 and above, the GetFirmwareEnvironmentVariable Win32 API (designed to extract firmware
environment
variables) can be used. This API is not supported on non-UEFI firmware and will fail in a predictable way when
called - this
will identify a legacy BIOS. On UEFI firmware, the API can be called with dummy parameters, and while it will
still fail
(probably!) the resulting error code will be different from the legacy BIOS case.
For Windows 8/Server 2012 and above there's a more elegant solution in the form of the GetFirmwareType() API. This
returns an enum (integer) indicating the underlying firmware type.
PARAMETERS
-QueryType <String>
Use this parameter to force a particular query type (if not specified this will default to 'Auto')
Valid values are:
SetupLog - look for the machine firmware type in the Windows Setup log file
GetFirmwareEnvironmentVariable - uses the GetFirmwareEnvironmentVariable Win32 API call (Windows 7/Server
208R2 and above)
GetFirmwareType - uses the GetFirmwareType Win32 API call (Windows 8/Server 2012R2 and above)
Auto - uses the most appropriate technique depending on the underlying OS version
Required? false
Position? 1
Default value Auto
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
OUTPUTS
['FirmwareType'] PS Custom object describing the machine firmware type
NOTES
Can only run against the local machine currently
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-FirmwareType
Determines the firmware type of the current machine using the most appropriate technique based on OS version
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-FirmwareType -Auto
Determines the firmware type of the current machine using the most appropriate technique based on OS version
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-FirmwareType -SetupLog
Determines the firmware type of the current machine by reading the Setup log file
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Get-FirmwareType -GetFirmwareType
Determines the firmware type of the current machine by using the GetFirmwareType() API call. (Windows 8+ only)
RELATED LINKS
SYNOPSIS
This cmdlet determines the underlying system firmware (BIOS) type - either UEFI or Legacy BIOS.
SYNTAX
Get-FirmwareType [[-QueryType] <String>] [<CommonParameters>]
DESCRIPTION
This cmdlet determines the underlying system firmware (BIOS) type - either UEFI or Legacy BIOS.
The function will use one of three methods to determine the firmware type:
The first method relies on the fact that Windows setup detects the firmware type as a part of the Windows
installation
routine and records its findings in the setupact.log file in the \\Windows\\Panther folder. It's a trivial task to
use
Select-String to extract the relevant line from this file and to pick off the (U)EFI or BIOS keyword it contains.
To do a proper job there are two choices; both involve using Win32 APIs which we call from PowerShell through a
compiled
(Add-Type) class using P/Invoke.
For Windows 7/Server 2008R2 and above, the GetFirmwareEnvironmentVariable Win32 API (designed to extract firmware
environment
variables) can be used. This API is not supported on non-UEFI firmware and will fail in a predictable way when
called - this
will identify a legacy BIOS. On UEFI firmware, the API can be called with dummy parameters, and while it will
still fail
(probably!) the resulting error code will be different from the legacy BIOS case.
For Windows 8/Server 2012 and above there's a more elegant solution in the form of the GetFirmwareType() API. This
returns an enum (integer) indicating the underlying firmware type.
PARAMETERS
-QueryType <String>
Use this parameter to force a particular query type (if not specified this will default to 'Auto')
Valid values are:
SetupLog - look for the machine firmware type in the Windows Setup log file
GetFirmwareEnvironmentVariable - uses the GetFirmwareEnvironmentVariable Win32 API call (Windows 7/Server
208R2 and above)
GetFirmwareType - uses the GetFirmwareType Win32 API call (Windows 8/Server 2012R2 and above)
Auto - uses the most appropriate technique depending on the underlying OS version
Required? false
Position? 1
Default value Auto
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
OUTPUTS
['FirmwareType'] PS Custom object describing the machine firmware type
NOTES
Can only run against the local machine currently
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-FirmwareType
Determines the firmware type of the current machine using the most appropriate technique based on OS version
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-FirmwareType -Auto
Determines the firmware type of the current machine using the most appropriate technique based on OS version
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-FirmwareType -SetupLog
Determines the firmware type of the current machine by reading the Setup log file
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Get-FirmwareType -GetFirmwareType
Determines the firmware type of the current machine by using the GetFirmwareType() API call. (Windows 8+ only)
RELATED LINKS