forked from felix068/LinuxGate
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwin11_testing.ps1
More file actions
695 lines (555 loc) · 19.8 KB
/
win11_testing.ps1
File metadata and controls
695 lines (555 loc) · 19.8 KB
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
#requires -Version 5.1
[CmdletBinding()]
param(
[switch]$Force = $false,
[switch]$Revert = $false,
[switch]$SkipDebian = $false,
[int]$DebianPartitionSizeGB = 4,
[switch]$InsecureTls = $true
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# Networking defaults
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if ($InsecureTls) {
try {
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) {
return true;
}
}
"@
} catch {}
[System.Net.ServicePointManager]::CertificatePolicy =
New-Object TrustAllCertsPolicy
if (
-not (
[System.Management.Automation.PSTypeName]`
"ServerCertificateValidationCallback"
).Type
) {
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback {
public static void Ignore() {
ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
}
}
"@
try { Add-Type $certCallback } catch {}
}
try { [ServerCertificateValidationCallback]::Ignore() } catch {}
}
# Downloads
$BaseUrl = "https://tpm28.com/filepool"
$RefindZipUrl = "$BaseUrl/refind-bin-0.14.2.zip"
$PreLoaderUrl = "$BaseUrl/PreLoader.efi"
$HashToolUrl = "$BaseUrl/HashTool.efi"
$DebianIsoUrl =
"https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.3.0-amd64-netinst.iso"
$DebianIsoName = "debian-13.3.0-amd64-netinst.iso"
# Defaults
$EspLetter = "Y"
$DebianLetter = "X"
$DebianLabel = "DEBIAN"
function Write-Log {
param(
[Parameter(Mandatory = $true)][string]$Message,
[ValidateSet("Gray", "Cyan", "Green", "Yellow", "Red", "White")]
[string]$Color = "Gray"
)
Write-Host "[$(Get-Date -Format 'HH:mm:ss')] $Message" -ForegroundColor $Color
}
function Test-Administrator {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
return $principal.IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
}
function Invoke-DiskpartScript {
param([Parameter(Mandatory = $true)][string]$ScriptText)
$tmp = [IO.Path]::GetTempFileName()
try {
$ScriptText | Out-File $tmp -Encoding ASCII
diskpart /s $tmp 2>&1 | Out-Null
} finally {
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
}
}
function Get-GuidDLower {
param([Parameter(Mandatory = $true)][Guid]$Guid)
$Guid.ToString("D").ToLower()
}
function Mount-Esp {
param([Parameter(Mandatory = $true)][string]$Letter)
if (Test-Path "${Letter}:\") {
Invoke-DiskpartScript -ScriptText @"
select volume $Letter
remove letter=$Letter
exit
"@
Start-Sleep -Seconds 1
}
$winPart = Get-Partition -DriveLetter C
$espPart =
Get-Partition -DiskNumber $winPart.DiskNumber |
Where-Object {
$_.GptType -eq "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}"
} |
Select-Object -First 1
if (-not $espPart) {
throw "ESP not found on disk $($winPart.DiskNumber)."
}
Invoke-DiskpartScript -ScriptText @"
select disk $($espPart.DiskNumber)
select partition $($espPart.PartitionNumber)
assign letter=$Letter
exit
"@
$tries = 0
while (-not (Test-Path "${Letter}:\") -and $tries -lt 10) {
Start-Sleep -Seconds 1
$tries++
}
if (-not (Test-Path "${Letter}:\")) {
throw "Failed to mount ESP as ${Letter}:"
}
return "${Letter}:"
}
function Dismount-Letter {
param([Parameter(Mandatory = $true)][string]$Letter)
if (Test-Path "${Letter}:\") {
Invoke-DiskpartScript -ScriptText @"
select volume $Letter
remove letter=$Letter
exit
"@
}
}
function Ensure-VolumeLetterByLabel {
param(
[Parameter(Mandatory = $true)][string]$Label,
[Parameter(Mandatory = $true)][string]$Letter
)
$vol = Get-Volume -ErrorAction SilentlyContinue |
Where-Object { $_.FileSystemLabel -eq $Label } |
Select-Object -First 1
if ($vol -and $vol.DriveLetter) {
if ($vol.DriveLetter -ne $Letter) {
$part = Get-Partition -DriveLetter $vol.DriveLetter
Set-Partition -DiskNumber $part.DiskNumber `
-PartitionNumber $part.PartitionNumber `
-NewDriveLetter $Letter
}
return "${Letter}:"
}
$cim = Get-CimInstance Win32_Volume -Filter "Label='$Label'" `
-ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $cim) {
return $null
}
if ($cim.DriveLetter -and $cim.DriveLetter.TrimEnd(":") -eq $Letter) {
return "${Letter}:"
}
$deviceId = $cim.DeviceID
if (-not $deviceId.EndsWith("\")) {
$deviceId = "$deviceId\"
}
# Assign letter using mountvol (works even if previously hidden)
& mountvol "${Letter}:" $deviceId | Out-Null
if (-not (Test-Path "${Letter}:\")) {
throw "Failed to assign ${Letter}: to volume labeled '$Label'."
}
return "${Letter}:"
}
function Get-PartitionGuidForLetter {
param([Parameter(Mandatory = $true)][string]$Letter)
$p = Get-Partition -DriveLetter $Letter -ErrorAction SilentlyContinue
if ($p -and $p.Guid) {
return (Get-GuidDLower -Guid $p.Guid)
}
return $null
}
function Write-RefindConfig {
param(
[Parameter(Mandatory = $true)][string]$EspPath,
[Parameter(Mandatory = $true)][bool]$IncludeDebian,
[Parameter()][string]$DebianGuidD,
[Parameter()][string]$DebianFsLabel
)
$configPath = Join-Path $EspPath "EFI\refind\refind.conf"
$base = @"
timeout 10
scanfor manual
dont_scan_dirs ESP:/EFI/boot,EFI/boot,EFI/Microsoft
dont_scan_files shimx64.efi,PreLoader.efi,HashTool.efi,loader.efi,refind_x64.efi,bootmgfw.efi,bootx64.efi,grubx64.efi
dont_scan_volumes "Recovery","SYSTEM"
use_graphics_for windows
menuentry "Windows" {
icon /EFI/refind/icons/os_win8.png
firmware_bootnum 0001
}
"@
if (-not $IncludeDebian) {
Set-Content -Path $configPath -Value $base -Encoding UTF8
return
}
$volumeLine =
if ($DebianGuidD) {
" volume $DebianGuidD"
} else {
" volume `"$DebianFsLabel`""
}
$debian = @"
menuentry "Debian Installer" {
icon /EFI/refind/icons/os_debian.png
$volumeLine
loader /EFI/BOOT/BOOTX64.EFI
}
"@
Set-Content -Path $configPath -Value ($base + $debian) -Encoding UTF8
}
function Start-BitsDownload {
param(
[Parameter(Mandatory = $true)][string]$Url,
[Parameter(Mandatory = $true)][string]$Destination
)
$job = Start-BitsTransfer -Source $Url -Destination $Destination `
-Asynchronous -DisplayName "Download: $([IO.Path]::GetFileName($Destination))" `
-ErrorAction Stop
$jobId = $job.JobId
while ($true) {
$j = Get-BitsTransfer -Id $jobId -ErrorAction SilentlyContinue
if (-not $j) { break }
if ($j.JobState -in @("Connecting", "Transferring")) {
$pct = 0
if ($j.BytesTotal -gt 0) {
$pct = [math]::Round(($j.BytesTransferred / $j.BytesTotal) * 100, 1)
}
Write-Progress -Activity "Downloading ISO" -PercentComplete $pct `
-Status "$pct% ($([math]::Round($j.BytesTransferred / 1MB, 1)) MB)"
Start-Sleep -Seconds 2
continue
}
if ($j.JobState -eq "Suspended") {
Resume-BitsTransfer -BitsJob $j | Out-Null
Start-Sleep -Seconds 1
continue
}
if ($j.JobState -eq "Transferred") {
Complete-BitsTransfer -BitsJob $j
break
}
if ($j.JobState -eq "Error") {
try { Remove-BitsTransfer -BitsJob $j } catch {}
throw "BITS transfer failed."
}
if ($j.JobState -in @("Cancelled", "Acknowledged")) {
throw "BITS ended unexpectedly (state=$($j.JobState))."
}
Start-Sleep -Seconds 1
}
Write-Progress -Activity "Downloading ISO" -Completed
}
function Ensure-VolumeNotEncrypted {
param([Parameter(Mandatory = $true)][string]$DriveLetter)
$out = manage-bde -status "${DriveLetter}:" 2>&1 | Out-String
$needsDecryption = $false
if ($out -match "Percentage Encrypted:\s*(\d+\.?\d*)%?") {
if ([double]$matches[1] -gt 0) { $needsDecryption = $true }
}
if (
$out -match "Conversion Status:\s*(Encryption in Progress|Used Space Only Encrypted|Fully Encrypted)" -or
$out -match "Protection Status:\s*(Protection On)"
) {
$needsDecryption = $true
}
if (-not $needsDecryption) {
return
}
Write-Log "BitLocker detected on ${DriveLetter}:, disabling..." "Yellow"
manage-bde -off "${DriveLetter}:" 2>&1 | Out-Null
$timeoutSec = 600
$elapsed = 0
$interval = 3
while ($elapsed -lt $timeoutSec) {
Start-Sleep -Seconds $interval
$elapsed += $interval
$out = manage-bde -status "${DriveLetter}:" 2>&1 | Out-String
if ($out -match "Percentage Encrypted:\s*(\d+\.?\d*)%?") {
$enc = [double]$matches[1]
$pct = [math]::Round(100 - $enc, 1)
Write-Progress -Activity "Decrypting ${DriveLetter}:" `
-PercentComplete $pct -Status "$pct% ($elapsed sec)"
if ($enc -eq 0) { break }
}
if ($out -match "Conversion Status:\s*Fully Decrypted") { break }
if ($out -match "État de la conversion:\s*Intégralement déchiffré") { break }
}
Write-Progress -Activity "Decrypting ${DriveLetter}:" -Completed
}
function Invoke-Revert {
Write-Log "Reverting rEFInd..." "Cyan"
$esp = $null
try {
$esp = Mount-Esp -Letter $EspLetter
$refindDir = Join-Path $esp "EFI\refind"
if (Test-Path $refindDir) {
Remove-Item -Path $refindDir -Recurse -Force
}
bcdedit /set "{bootmgr}" path \EFI\Microsoft\Boot\bootmgfw.efi 2>$null |
Out-Null
bcdedit /set "{bootmgr}" description "Windows Boot Manager" 2>$null |
Out-Null
$fw = bcdedit /enum firmware 2>&1
if ($fw -match "rEFInd.*\{([a-f0-9\-]+)\}") {
$id = "{$($matches[1])}"
bcdedit /delete $id 2>$null | Out-Null
}
bcdedit /set "{fwbootmgr}" default "{bootmgr}" 2>$null | Out-Null
Write-Log "Revert complete." "Green"
} finally {
if ($esp) { Dismount-Letter -Letter $EspLetter }
}
Write-Host ""
Write-Host "Note: the DEBIAN partition is not removed." -ForegroundColor Yellow
}
function Install-Refind {
Write-Log "Installing rEFInd to ESP..." "Cyan"
$tmpDir = Join-Path $env:TEMP "refind-$([Guid]::NewGuid().ToString('N'))"
New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null
$esp = $null
try {
$refindZip = Join-Path $tmpDir "refind.zip"
$preLoader = Join-Path $tmpDir "PreLoader.efi"
$hashTool = Join-Path $tmpDir "HashTool.efi"
Invoke-WebRequest -Uri $RefindZipUrl -OutFile $refindZip -UseBasicParsing
Invoke-WebRequest -Uri $PreLoaderUrl -OutFile $preLoader -UseBasicParsing
Invoke-WebRequest -Uri $HashToolUrl -OutFile $hashTool -UseBasicParsing
$extract = Join-Path $tmpDir "extract"
Expand-Archive -LiteralPath $refindZip -DestinationPath $extract -Force
$refindRoot =
Get-ChildItem -Path $extract -Directory -Filter "refind*" |
Select-Object -First 1
if (-not $refindRoot) {
throw "Failed to locate extracted rEFInd directory."
}
$refindSource = Join-Path $refindRoot.FullName "refind"
$esp = Mount-Esp -Letter $EspLetter
$dest = Join-Path $esp "EFI\refind"
if (Test-Path $dest) {
Remove-Item -Path $dest -Recurse -Force
}
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Copy-Item -Path "$refindSource\*" -Destination $dest -Recurse -Force
@(
"drivers_ia32",
"drivers_aa64",
"tools_ia32",
"tools_aa64",
"refind_ia32.efi",
"refind_aa64.efi"
) | ForEach-Object {
$p = Join-Path $dest $_
if (Test-Path $p) {
Remove-Item -Path $p -Recurse -Force
}
}
Copy-Item -Path $preLoader -Destination (Join-Path $dest "shimx64.efi") `
-Force
Copy-Item -Path (Join-Path $dest "refind_x64.efi") `
-Destination (Join-Path $dest "loader.efi") -Force
Copy-Item -Path $hashTool -Destination (Join-Path $dest "HashTool.efi") `
-Force
# Minimal config now; Debian entry is added later if requested
Write-RefindConfig -EspPath $esp -IncludeDebian:$false `
-DebianGuidD $null -DebianFsLabel $DebianLabel
# Disable hibernation / Fast Startup
powercfg /h off 2>&1 | Out-Null
# Create a dedicated UEFI entry (keep Windows Boot Manager intact)
$bootmgr = bcdedit /enum "{bootmgr}" 2>&1
if ($bootmgr -match "refind|shimx64") {
bcdedit /set "{bootmgr}" path \EFI\Microsoft\Boot\bootmgfw.efi |
Out-Null
bcdedit /set "{bootmgr}" description "Windows Boot Manager" | Out-Null
}
$copy = bcdedit /copy "{bootmgr}" /d "rEFInd Boot Manager" 2>&1
if ($copy -match "\{([a-f0-9\-]+)\}") {
$entry = $matches[0]
bcdedit /set $entry path \EFI\refind\shimx64.efi | Out-Null
bcdedit /set "{fwbootmgr}" displayorder $entry /addfirst 2>$null
bcdedit /set "{fwbootmgr}" default $entry 2>$null
} else {
# Fallback: modify {bootmgr}
bcdedit /set "{bootmgr}" path \EFI\refind\shimx64.efi | Out-Null
bcdedit /set "{bootmgr}" description "rEFInd Boot Manager" | Out-Null
}
Write-Log "rEFInd installed." "Green"
} finally {
if ($esp) { Dismount-Letter -Letter $EspLetter }
Remove-Item -Path $tmpDir -Recurse -Force -ErrorAction SilentlyContinue
}
}
function New-OrReuseDebianPartition {
param([Parameter(Mandatory = $true)][int]$SizeGB)
# If it already exists (maybe hidden), bring it back as X:
$existing = Ensure-VolumeLetterByLabel -Label $DebianLabel -Letter $DebianLetter
if ($existing) {
$guid = Get-PartitionGuidForLetter -Letter $DebianLetter
return @{
Drive = $existing
GuidD = $guid
}
}
$sizeMB = $SizeGB * 1024
$cPart = Get-Partition -DriveLetter C
$cVol = Get-Volume -DriveLetter C
$minFree = 10GB
$need = ($sizeMB * 1MB) + $minFree
if ($cVol.SizeRemaining -lt $need) {
throw "Not enough free space on C: (need ~$( [math]::Round($need / 1GB, 1) ) GB)."
}
$supported = $cPart | Get-PartitionSupportedSize
$shrinkBytes = $sizeMB * 1MB
$maxShrink = $supported.SizeMax - $supported.SizeMin
if ($shrinkBytes -gt $maxShrink) {
throw "Cannot shrink C: by ${SizeGB}GB (max ~$( [math]::Round($maxShrink / 1GB, 1) ) GB)."
}
Write-Log "Creating ${SizeGB}GB FAT32 partition '$DebianLabel'..." "Cyan"
Resize-Partition -DriveLetter C -Size ($cPart.Size - $shrinkBytes)
Start-Sleep -Seconds 2
Invoke-DiskpartScript -ScriptText @"
select disk $($cPart.DiskNumber)
create partition primary size=$sizeMB
format fs=fat32 quick label=$DebianLabel
assign letter=$DebianLetter
exit
"@
$tries = 0
while (-not (Test-Path "${DebianLetter}:\") -and $tries -lt 15) {
Start-Sleep -Seconds 1
$tries++
}
if (-not (Test-Path "${DebianLetter}:\")) {
throw "Failed to create/assign ${DebianLetter}: for Debian partition."
}
Ensure-VolumeNotEncrypted -DriveLetter $DebianLetter
$guid = Get-PartitionGuidForLetter -Letter $DebianLetter
return @{
Drive = "${DebianLetter}:"
GuidD = $guid
}
}
function Install-DebianIsoToPartition {
param(
[Parameter(Mandatory = $true)][string]$PartitionDrive
)
$tmpDir = Join-Path $env:TEMP "debian-$([Guid]::NewGuid().ToString('N'))"
New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null
$isoPath = Join-Path $tmpDir $DebianIsoName
try {
Write-Log "Downloading Debian ISO..." "Cyan"
$downloaded = $false
try {
Start-BitsDownload -Url $DebianIsoUrl -Destination $isoPath
$downloaded = $true
} catch {
Write-Log "BITS failed; using Invoke-WebRequest..." "Yellow"
}
if (-not $downloaded) {
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $DebianIsoUrl -OutFile $isoPath -UseBasicParsing
$ProgressPreference = "Continue"
}
if (-not (Test-Path $isoPath)) {
throw "ISO download failed."
}
Write-Log "Mounting ISO..." "Cyan"
$img = Mount-DiskImage -ImagePath $isoPath -PassThru
$vol = $img | Get-Volume
if (-not $vol.DriveLetter) {
Start-Sleep -Seconds 2
$vol =
Get-Volume |
Where-Object { $_.DriveType -eq "CD-ROM" -and $_.Size -gt 0 } |
Select-Object -First 1
}
if (-not $vol -or -not $vol.DriveLetter) {
throw "ISO mounted but no drive letter was assigned."
}
$src = "$($vol.DriveLetter):\*"
$dst = "$PartitionDrive\"
Write-Log "Copying ISO contents to $PartitionDrive..." "Cyan"
Copy-Item -Path $src -Destination $dst -Recurse -Force
Dismount-DiskImage -ImagePath $isoPath | Out-Null
Write-Log "Debian installer copied." "Green"
} finally {
try {
Dismount-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue |
Out-Null
} catch {}
Remove-Item -Path $tmpDir -Recurse -Force -ErrorAction SilentlyContinue
}
}
if (-not (Test-Administrator)) {
Write-Log "Run this script as Administrator." "Red"
exit 1
}
if ($Revert) {
Invoke-Revert
exit 0
}
if (-not $Force) {
$already = bcdedit /enum firmware 2>$null | Select-String -Pattern "refind"
if ($already) {
Write-Log "rEFInd entry detected. Use -Force to reinstall." "Yellow"
}
}
try {
Install-Refind
if ($SkipDebian) {
$esp = Mount-Esp -Letter $EspLetter
try {
Write-RefindConfig -EspPath $esp -IncludeDebian:$false `
-DebianGuidD $null -DebianFsLabel $DebianLabel
} finally {
Dismount-Letter -Letter $EspLetter
}
Write-Log "Done (Windows entry only)." "Green"
exit 0
}
$info = New-OrReuseDebianPartition -SizeGB $DebianPartitionSizeGB
$drive = $info.Drive
$guidD = $info.GuidD
Install-DebianIsoToPartition -PartitionDrive $drive
$esp = Mount-Esp -Letter $EspLetter
try {
Write-RefindConfig -EspPath $esp -IncludeDebian:$true `
-DebianGuidD $guidD -DebianFsLabel $DebianLabel
} finally {
Dismount-Letter -Letter $EspLetter
}
Dismount-Letter -Letter $DebianLetter
Write-Host ""
Write-Log "Complete. rEFInd menu: Windows + Debian Installer." "Green"
Write-Host ""
Write-Host "First boot (Secure Boot): enroll loader.efi via HashTool if prompted." `
-ForegroundColor Yellow
$r = Read-Host "Restart now? (y/n)"
if ($r -match "^(y|Y)$") {
Restart-Computer -Force
}
} catch {
Write-Log $_.Exception.Message "Red"
Write-Log "Tip: you can run with -Revert to restore Windows boot." "Yellow"
exit 1
}