-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-BCDFirmWareType.ps1
50 lines (44 loc) · 1.28 KB
/
Get-BCDFirmWareType.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function Get-BCDFirmWareType
{
<#
.SYNOPSIS
Determines kind of Firmwaretype.
.DESCRIPTION
This functions works only on Windows PE and determines the Type of Bios from the the Registry. Return-Values are Legacy
or UEFI or $true/$false if $ReturnUEFI was chosen
.EXAMPLE
Get-BCDFirmWareType
Returns UEFI or Legacy
.EXAMPLE
Get-BCDFirmWareType -UEFI
Returns $true if Firmwaretype is UEFI or $false for Legacy-Bios
.NOTES
Author: Holger Voges
Version: 1.0.1
Date: 2019-05-06
#>
[cmdletbinding()]
param(
# Returns $true instead of 'UEFI' or $false instead of 'BIOS'
[Switch]$Silent
)
If ( $FirmWareType = ( Get-ItemProperty -Path "Registry::Hkey_Local_machine\System\CurrentControlSet\Control\" -Name PEFirmwareType -ErrorAction SilentlyContinue ).PEFirmwareType )
{
Switch ( $FirmWareType )
{
1 { If ( $Silent ) { $False } Else { "BIOS" } }
2 { If ( $Silent ) { $true } Else { "UEFI" } }
}
}
Else
{
If (( Get-BCDCurrentEntry ).path -like "*.efi")
{
If ( $Silent ) { $true } Else { "UEFI" }
}
Else
{
If ( $Silent ) { $False } Else { "BIOS" }
}
}
}