forked from MicksITBlogs/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BootEnvironment.ps1
29 lines (26 loc) · 1016 Bytes
/
BootEnvironment.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
<#
.SYNOPSIS
Check Boot Environment
.DESCRIPTION
This script reads the setupact.log file to determine if the system is configured for BIOS or UEFI.
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.142
Created on: 9/25/2020 11:59 AM
Created by: Mick Pletcher
Filename: BootEnvironment.ps1
===========================================================================
#>
Try {
$Output = (Get-Content -Path (((Get-ChildItem -Path ($env:windir + '\Panther') -Recurse -Filter setupact.log -ErrorAction SilentlyContinue)[0]).FullName) -ErrorAction SilentlyContinue | Where-Object {$_ -like "*Detected boot environment*"}).Replace("Detected boot environment:", "~").Split("~")[1].Trim()
If ($Output -eq 'BIOS') {
Write-Output 'BIOS'
Exit 0
} elseif ($Output -eq 'UEFI') {
Write-Output 'UEFI'
Exit 1
}
} Catch {
Write-Output 'Unknown'
Exit 2
}