-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-UEFISecureBootInfo.ps1
335 lines (310 loc) · 8.74 KB
/
get-UEFISecureBootInfo.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<#
.SYNOPSIS
Collect information for SecureBoot configuration
.DESCRIPTION
Collect information for SecureBoot configuration
.EXAMPLE
C:\PS> get-UEFISecureBootInfo.ps1
.PARAMETER LogPath
Path to Logfile.
.NOTES
Author : Fabian Niesen (Dell EMC)
Filename : get-UEFISecureBootInfo.ps1
Requires : PowerShell Version 3.0
Version : 1.1
History : 1.0.0 FN 29.10.2018 initial version
1.1. FN 06.11.2018 Proxy Support
#>
Param(
[Parameter(Mandatory=$false, Position=0, ValueFromPipeline=$False)]
[String]$LogPath="C:\Temp\",
[Boolean]$DellTools,
[Boolean]$InstallDellTools=$false,
[Boolean]$UseProxy
)
Write-Verbose "Check Admin privilages"
### Proof for administrative permissions (UAC) and start EventLog Handling
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Error -Category PermissionDenied -Exception "Administrative Permissions required" -RecommendedAction "Run as administrator"
break
}
IF ($UseProxy -eq $true)
{
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$IPPC = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Proxy $proxy -ProxyCredential $($proxy.credentials)
$IMC = Install-Module -Name DellBIOSProvider -RequiredVersion 1.0 -Force -Proxy $proxy -ProxyCredential $($proxy.credentials)
} ELSE {
$IPPC = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
$IMC = Install-Module -Name DellBIOSProvider -RequiredVersion 1.0 -Force
}
IF ($LogPath.EndsWith("\") -like "False") { $LogPath =$LogPath+"\" }
IF (!(Test-Path $LogPath)) { new-item -Path $LogPath -ItemType directory }
$hostname = Hostname
$date = get-date -format yyyyMMdd-HHmm
$file = $LogPath+$date+"-"+$hostname+"-UEFILog.txt"
$filebytes = $LogPath+$date+"-"+$hostname+"-UEFILog-Bytes.txt"
"Vendor: "+(Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer | Out-File $file -Append
"Device: "+(Get-WmiObject -Class:Win32_ComputerSystem).Model | Out-File $file -Append
"Serial: "+(Get-WmiObject -Class:Win32_BIOS).SerialNumber | Out-File $file -Append
"Bios Ver.: "+(Get-WmiObject -Class:Win32_BIOS).SMBIOSBIOSVersion | Out-File $file -Append
IF ( (Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer -like "Dell*")
{
# Test VC2010 und VC2012
Write-Output "Dell detected, starting BIOS analysis"
IF ((get-Module -Name DellBIOSProvider).count -lt 1)
{
Write-Verbose "Test DellBIOSProvider"
Try
{
Import-Module DellBIOSProvider
}
Catch
{
Write-Verbose "Modul DellBiosProvider not found"
}
}
IF ( (get-Module -Name DellBIOSProvider).count -lt 1)
{
Write-Output "Install needed Modules"
Write-Verbose "Install NuGet"
Try { $IPPC } catch {Write-Warning "NuGet installation failed"}
Write-Verbose "Install DellBIOSProvider"
Try { $IMC } catch {Write-Warning "DellBIOSProvider installation failed"}
Import-Module DellBIOSProvider
}
Write-Verbose "Test DellBIOSProvider Path"
$DellTools = $true
Try { ( Test-Path DellSmbios:\ ) -eq $true } Catch { Write-Warning "Dell Bios Tools failed"; $DellTools = $false }
Write-Verbose "DellTools: $DellTools"
IF ( $DellTools -eq $true)
{
Write-Verbose "Start Dell Bios query"
$DellBIOS = get-childitem -path DellSmbios:\ | select category | foreach { get-childitem -path @("DellSmbios:\" + $_.Category) | select attribute, currentvalue, possiblevalues } | Sort-Object -Property attribute
$DellBIOS | FT -AutoSize |Out-File $file -Append
} ELSE { "Dell Tools Failed"|Out-File $file -Append}
}
IF (Confirm-SecureBootUEFI) {"SecureBoot enabled" | Out-File $file -Append}
ELSE {"SecureBoot disabled" | Out-File $file -Append}
"--- SecureBoot Policy ---"| Out-File $file -Append
Get-SecureBootPolicy | ft -AutoSize | Out-File $file -Append
### Start Get-SecureBootUEFI queries ###
"--- db ---" | Out-File $file -Append
"--- db ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name db | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name db).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- dbt ---" | Out-File $file -Append
"--- dbt ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name dbt | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name dbt).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- dbx ---" | Out-File $file -Append
"--- dbx ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name dbx | fl -Expand| Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name dbx).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- dbDefault ---" | Out-File $file -Append
"--- dbDefault ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name dbDefault | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name dbDefault).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- dbtDefault ---" | Out-File $file -Append
"--- dbtDefault ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name dbtDefault | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name dbtDefault).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- dbxDefault ---" | Out-File $file -Append
"--- dbxDefault ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name dbxDefault | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name dbxDefault).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- KEK ---" | Out-File $file -Append
"--- KEK ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name KEK | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name KEK).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- KEKDefault --" | Out-File $file -Append
"--- KEKDefault --" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name KEKDefault | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name KEKDefault).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- PK ---" | Out-File $file -Append
"--- PK ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name PK | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name PK).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- PKDefault ---" | Out-File $file -Append
"--- PKDefault ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name PKDefault | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name PKDefault).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- SecureBoot ---" | Out-File $file -Append
"--- SecureBoot ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name SecureBoot | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name SecureBoot).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
"--- SetupMode ---" | Out-File $file -Append
"--- SetupMode ---" | Out-File $filebytes -Append
try
{
Get-SecureBootUEFI -Name SetupMode | fl | Out-File $file -Append
}
catch
{
"No Values provided" | Out-File $file -Append
}
Try
{
[System.BitConverter]::ToString((Get-SecureBootUEFI -Name SetupMode).Bytes) | Out-File $filebytes -Append
}
catch
{
"No Bytes provided" | Out-File $filebytes -Append
}
Write-Output "Logfile written to $file"
Write-Output "Bytes Logfile written to $filebytes"