forked from gangstanthony/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-BootConfigurationData.ps1
35 lines (29 loc) · 1004 Bytes
/
Get-BootConfigurationData.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
# https://www.reddit.com/r/PowerShell/comments/4fyfau/does_anyone_know_of_a_module_or_wrapper_for/
# must be admin
function Get-BootConfigurationData {
param (
$bcdeditpath = (Join-Path $env:SystemRoot 'system32\bcdedit.exe')
)
$bootconfigurationdata = iex $bcdeditpath
$bootconfigurationdata += ''
$hash = $null
$result = foreach ($line in $bootconfigurationdata) {
if ($line -eq '') {
if ($hash) {
[pscustomobject]$hash
}
$hash = @{}
continue
}
if ($line.startswith('-----')) { continue }
if ($line.startswith('Windows Boot')) {
$hash.Add('Type', $line)
} else {
$name = $line.Substring(0, $line.IndexOf(' '))
$value = $line.Substring($line.IndexOf(' ')).trim()
$hash.Add($name, $value)
}
}
$props = $result | % {gm -in $_ -ty *property} | % name | select -u | sort
$result | select $props
}