-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMigrationMerlin.ps1
More file actions
1424 lines (1254 loc) · 62.8 KB
/
Copy pathMigrationMerlin.ps1
File metadata and controls
1424 lines (1254 loc) · 62.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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.SYNOPSIS
MigrationMerlin - Unified interactive TUI for USMT PC-to-PC migration.
.DESCRIPTION
Single-file entry point that wraps destination-setup.ps1, source-capture.ps1,
and post-migration-verify.ps1 behind an arrow-key navigable text UI.
Features animated banner, interactive configuration panels, spinners,
real-time progress bars, and persisted configuration in
%LOCALAPPDATA%\MigrationMerlin\config.json. Auto-elevates to Administrator
via UAC on launch and keeps the console awake (prevents display sleep) for
the duration of a long-running capture or restore. This is the recommended
launch surface for interactive use; the underlying scripts remain available
for scripted / unattended deployments.
.EXAMPLE
PS> .\MigrationMerlin.ps1
Launches the TUI with defaults. The menu walks the user through setup,
capture, restore, verification, and cleanup in sequence.
.EXAMPLE
PS> .\MigrationMerlin.bat
Double-click wrapper that launches the TUI via PowerShell with the
correct execution policy. Equivalent to the direct .ps1 invocation.
.EXAMPLE
PS> .\MigrationMerlin.ps1
(Once inside the TUI, pick "Load Configuration" to restore a previously
saved run configuration from %LOCALAPPDATA%\MigrationMerlin\config.json.)
Launches the TUI and resumes from a saved configuration.
.INPUTS
None. Input is collected interactively through the TUI.
.OUTPUTS
None. Exit code 0 indicates a clean exit. Logs from individual phases are
written under the migration folder's Logs subdirectory.
.NOTES
- Requires Windows PowerShell 5.1 or later.
- Requires Administrator privileges (auto-elevates via UAC).
- Minimum console width 64 columns; the script attempts to widen to 80.
- Uses VT100 / ANSI escape sequences; Windows 10 1511+ or Windows Terminal
recommended.
- Prevents system and display sleep while running via
SetThreadExecutionState.
.LINK
https://github.com/supermarsx/migration-merlin
.LINK
.\scripts\destination-setup.ps1
.LINK
.\scripts\source-capture.ps1
.LINK
.\scripts\post-migration-verify.ps1
#>
#Requires -Version 5.1
[CmdletBinding()]
param()
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# ════════════════════════════════════════════════════════════════
# MODULE IMPORTS
# ════════════════════════════════════════════════════════════════
# Phase 1 shared modules. Imported here so Request-Elevation can marshal
# $PSBoundParameters across UAC and Format-SafeParams can scrub param logs.
# MigrationUI is imported for completeness; the TUI keeps its own ANSI
# helpers because their colour/format contract differs from the module's
# (see note in the HELPERS section below).
Import-Module "$PSScriptRoot\modules\MigrationConstants.psm1" -Force -ErrorAction SilentlyContinue
Import-Module "$PSScriptRoot\modules\MigrationUI.psm1" -Force -ErrorAction SilentlyContinue
# Phase 3 / t1-e12: shared validators exposed in the TUI's scope so future
# interactive input handling can reuse Test-UncPath / Test-ProfileName etc.
Import-Module "$PSScriptRoot\modules\MigrationValidators.psm1" -Force -ErrorAction SilentlyContinue
. "$PSScriptRoot\modules\Invoke-Elevated.ps1"
. "$PSScriptRoot\modules\MigrationLogging.ps1"
# ════════════════════════════════════════════════════════════════
# BOOTSTRAP
# ════════════════════════════════════════════════════════════════
# Enable VT100 / ANSI sequences + keep-awake via kernel32
try {
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public static class MwKernel {
[DllImport("kernel32.dll")] public static extern IntPtr GetStdHandle(int h);
[DllImport("kernel32.dll")] public static extern bool GetConsoleMode(IntPtr h, out uint m);
[DllImport("kernel32.dll")] public static extern bool SetConsoleMode(IntPtr h, uint m);
[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);
// ES_CONTINUOUS=0x80000000 ES_SYSTEM_REQUIRED=0x1 ES_DISPLAY_REQUIRED=0x2
public static void KeepAwake() { SetThreadExecutionState(0x80000003); }
public static void AllowSleep() { SetThreadExecutionState(0x80000000); }
}
"@ -ErrorAction SilentlyContinue
# Enable VT100
$h = [MwKernel]::GetStdHandle(-11); $m = 0
[void][MwKernel]::GetConsoleMode($h, [ref]$m)
[void][MwKernel]::SetConsoleMode($h, $m -bor 4)
# Prevent sleep + screen off while TUI is running
[MwKernel]::KeepAwake()
}
catch {}
# Auto-elevate (marshals $PSBoundParameters across UAC via Invoke-Elevated helper).
Request-Elevation -ScriptPath $PSCommandPath -BoundParameters $PSBoundParameters
# Handle UNC paths — PS 5.1 can't Set-Location to \\server\share
$script:ScriptRoot = $PSScriptRoot
$script:ScriptsDir = Join-Path $PSScriptRoot 'scripts'
$script:IsUNC = $PSScriptRoot -match '^\\\\'
if (-not $script:IsUNC) {
Set-Location $PSScriptRoot
}
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$host.UI.RawUI.WindowTitle = 'MigrationMerlin'
# Minimum terminal size
if ([Console]::WindowWidth -lt 64) {
try { [Console]::WindowWidth = 80 } catch {}
}
# ════════════════════════════════════════════════════════════════
# ANSI CONSTANTS
# ════════════════════════════════════════════════════════════════
$E = [char]0x1B
$RST = "$E[0m"
$BLD = "$E[1m"
$cR = "$E[91m" # red
$cG = "$E[92m" # green
$cY = "$E[93m" # yellow
$cB = "$E[94m" # blue
$cM = "$E[95m" # magenta
$cC = "$E[96m" # cyan
$cW = "$E[97m" # white
$cGR = "$E[90m" # gray
# Spinner frames. Prefer $MigrationConstants.UI.SpinnerFrames (same braille
# sequence, centralized in Phase 1). Fall back to the original literal array
# if MigrationConstants isn't loaded for any reason.
if ($MigrationConstants -and $MigrationConstants.UI -and $MigrationConstants.UI.SpinnerFrames) {
$Spin = $MigrationConstants.UI.SpinnerFrames
}
else {
$Spin = @([char]0x280B, [char]0x2819, [char]0x2839, [char]0x2838,
[char]0x283C, [char]0x2834, [char]0x2826, [char]0x2827,
[char]0x2807, [char]0x280F)
}
# ════════════════════════════════════════════════════════════════
# STATE
# ════════════════════════════════════════════════════════════════
$script:Sel = 0
$script:Done = @{} # Action -> $true
$script:Items = @(
[pscustomobject]@{ Key='1'; Label='Setup Destination'; Tag='DEST';
Desc='Install USMT, create hidden network share (MigrationShare$), open firewall ports. Run on the NEW PC first.'; Action='Setup'
}
[pscustomobject]@{ Key='2'; Label='Capture Source'; Tag='SRC';
Desc='Scan user profiles, files & settings on the OLD PC and transfer to the destination share.'; Action='Capture'
}
[pscustomobject]@{ Key='3'; Label='Restore Data'; Tag='DEST';
Desc='Apply captured user state on the NEW PC via USMT LoadState. Steps 1 & 2 must be complete.'; Action='Restore'
}
[pscustomobject]@{ Key='4'; Label='Verify Migration'; Tag='DEST';
Desc='Compare pre-migration inventory with current state. Shows what migrated and what needs attention.'; Action='Verify'
}
[pscustomobject]@{ Key='5'; Label='Cleanup'; Tag='DEST';
Desc='Remove network share, firewall rules, and temporary migration data from the NEW PC.'; Action='Cleanup'
}
)
$script:TotalChoices = $script:Items.Count + 1 # +1 for Quit
# ════════════════════════════════════════════════════════════════
# HELPERS
# ════════════════════════════════════════════════════════════════
function Rep([string]$c, [int]$n) { if ($n -le 0) { '' }else { $c * $n } }
function Strip([string]$t) { $t -replace '\x1B\[[0-9;]*m', '' }
function PadR([string]$t, [int]$w) { $p = [Math]::Max(0, $w - (Strip $t).Length); "$t$(Rep ' ' $p)" }
function PadC([string]$t, [int]$w) {
$vis = (Strip $t).Length; $gap = [Math]::Max(0, $w - $vis)
$l = [Math]::Floor($gap / 2); $r = $gap - $l
"$(Rep ' ' $l)$t$(Rep ' ' $r)"
}
function HideCur { [Console]::Write("$E[?25l") }
function ShowCur { [Console]::Write("$E[?25h") }
function FlushKeys { while ([Console]::KeyAvailable) { [void][Console]::ReadKey($true) } }
function WaitKey { FlushKeys; return [Console]::ReadKey($true) }
# ════════════════════════════════════════════════════════════════
# CONFIG SAVE / LOAD / RESUME
# ════════════════════════════════════════════════════════════════
$script:ConfigDir = Join-Path $script:ScriptRoot '.mw-configs'
function Save-RunConfig([string]$Step, [hashtable]$Config) {
<# Save step config to JSON so the user can resume or re-use it. #>
if (-not (Test-Path $script:ConfigDir)) { New-Item $script:ConfigDir -ItemType Directory -Force | Out-Null }
$file = Join-Path $script:ConfigDir "$Step.json"
$Config['_saved'] = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
$Config | ConvertTo-Json -Depth 10 | Set-Content $file -Encoding UTF8
Write-Host " ${cG}$([char]0x2713)${RST} ${cGR}Config saved to $file${RST}"
}
function Load-RunConfig([string]$Step) {
<# Load saved config. Returns $null if none exists. #>
$file = Join-Path $script:ConfigDir "$Step.json"
if (-not (Test-Path $file)) { return $null }
try {
$json = Get-Content $file -Raw -Encoding UTF8 | ConvertFrom-Json
return $json
}
catch { return $null }
}
function Show-ConfigPrompt([string]$Step) {
<# If a saved config exists, offer to load it. Returns loaded config or $null. #>
$saved = Load-RunConfig $Step
if (-not $saved) { return $null }
Write-Host ""
Write-Host " ${cC}$([char]0x25B8)${RST} ${cW}Saved config found${RST} ${cGR}($($saved._saved))${RST}"
Write-Host " ${cC}L${RST} ${cW}Load saved config${RST} ${cC}N${RST} ${cW}Start fresh${RST}"
Write-Host " ${cC}$([char]0x25B8)${RST} " -NoNewline
ShowCur; FlushKeys
$k = [Console]::ReadKey($true); HideCur
switch ($k.KeyChar) {
'l' { Write-Host 'Load'; return $saved }
default { Write-Host 'Fresh'; return $null }
}
}
# ════════════════════════════════════════════════════════════════
# SHARE DISCOVERY & VALIDATION
# ════════════════════════════════════════════════════════════════
function Find-MigrationShares {
<# Scan ARP table for hosts with MigrationShare$. Fast — no broadcast scan. #>
$found = [System.Collections.Generic.List[pscustomobject]]::new()
# Parse ARP table for dynamic entries
$arpLines = arp -a 2>$null
$candidates = @()
foreach ($line in $arpLines) {
if ($line -match '^\s+(\d+\.\d+\.\d+\.\d+)\s+[0-9a-f-]+\s+dynamic') {
$candidates += $Matches[1]
}
}
# Add default gateway
try {
$gw = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue |
Select-Object -First 1).NextHop
if ($gw -and $gw -ne '0.0.0.0') { $candidates += $gw }
}
catch {}
$candidates = $candidates |
Where-Object { $_ -notmatch '\.(255|0)$' -and $_ -ne '255.255.255.255' } |
Select-Object -Unique
$myIPs = @()
try { $myIPs = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue).IPAddress } catch {}
foreach ($ip in $candidates) {
if ($ip -in $myIPs) { continue }
# Quick SMB port check (500 ms timeout)
$tcp = New-Object System.Net.Sockets.TcpClient
try {
$ar = $tcp.BeginConnect($ip, 445, $null, $null)
if ($ar.AsyncWaitHandle.WaitOne(500) -and $tcp.Connected) {
$tcp.EndConnect($ar)
if (Test-Path "\\$ip\MigrationShare`$" -ErrorAction SilentlyContinue) {
$name = $ip
try { $name = ([System.Net.Dns]::GetHostEntry($ip)).HostName.Split('.')[0] } catch {}
$found.Add([pscustomobject]@{ IP = $ip; Name = $name; Path = "\\$ip\MigrationShare`$" })
}
}
}
catch {} finally { $tcp.Dispose() }
}
return , $found.ToArray()
}
function Test-ShareAccess([string]$Path) {
<# Returns a PSCustomObject: .OK .Detail #>
if ($Path -notmatch '^\\\\[^\\]+\\[^\\]+') {
return [pscustomobject]@{ OK = $false; Detail = 'Invalid UNC format (expected \\HOST\Share)' }
}
$hostPart = ($Path -split '\\' | Where-Object { $_ })[0]
# Test-Path can be slow on unreachable hosts — pre-check with TCP 445
$tcp = New-Object System.Net.Sockets.TcpClient
try {
$ar = $tcp.BeginConnect($hostPart, 445, $null, $null)
if (-not ($ar.AsyncWaitHandle.WaitOne(2000) -and $tcp.Connected)) {
return [pscustomobject]@{ OK = $false; Detail = "Host $hostPart is not reachable (port 445 timeout)" }
}
$tcp.EndConnect($ar)
}
catch {
return [pscustomobject]@{ OK = $false; Detail = "Host $hostPart is not reachable" }
}
finally { $tcp.Dispose() }
if (Test-Path $Path -ErrorAction SilentlyContinue) {
return [pscustomobject]@{ OK = $true; Detail = 'Share accessible' }
}
return [pscustomobject]@{ OK = $false; Detail = "Host reachable but share not found or access denied" }
}
function Show-SharePicker {
<# Let the user scan or type a share, then validate it. Returns the UNC path. #>
Write-Host ""
Write-Host " ${BLD}${cW}Destination Share${RST}"
Write-Host " ${cGR}$(Rep ([char]0x2500) 40)${RST}"
Write-Host " ${cC}S${RST} ${cW}Scan network${RST} for MigrationShare`$"
Write-Host " ${cC}M${RST} ${cW}Enter path manually${RST}"
Write-Host ""
Write-Host " ${cC}$([char]0x25B8)${RST} " -NoNewline
ShowCur
$choice = $null
FlushKeys
while ($null -eq $choice) {
$k = [Console]::ReadKey($true)
switch -regex ("$($k.KeyChar)") {
'[sS]' { Write-Host 'Scan'; HideCur; $choice = 'scan' }
'[mM]' { Write-Host 'Manual'; HideCur; $choice = 'manual' }
default {
if ($k.Key -eq 'Enter') { Write-Host 'Scan'; HideCur; $choice = 'scan' }
}
}
}
$sharePath = $null
if ($choice -eq 'scan') {
Write-Host ""
# Animated scan
$scanDone = $false; $frame = 0
Write-Host " " -NoNewline
$shares = $null
# Run scan — show spinner between ARP parse and host checks
Write-Host "`r ${cC}$($Spin[0])${RST} ${cGR}Reading ARP table...${RST}" -NoNewline
$shares = Find-MigrationShares
Write-Host "`r ${cG}$([char]0x2713)${RST} ${cW}Scan complete${RST} "
if ($shares.Count -eq 0) {
Write-Host ""
Write-Host " ${cY}$([char]0x26A0)${RST} ${cY}No MigrationShare`$ found on the network.${RST}"
Write-Host " ${cGR}Make sure Step 1 was run on the destination PC first.${RST}"
Write-Host ""
$sharePath = Prompt-Text 'Enter share path manually' -Example '\\NEWPC\MigrationShare$' -Required
}
else {
Write-Host ""
Write-Host " ${BLD}${cW}Found $($shares.Count) share$(if($shares.Count -gt 1){'s'}):${RST}"
for ($i = 0; $i -lt $shares.Count; $i++) {
$sh = $shares[$i]
$display = $sh.Path
if ($sh.Name -ne $sh.IP) { $display += " ${cGR}($($sh.Name))${RST}" }
Write-Host " ${cC}$($i + 1)${RST} ${cW}$display${RST}"
}
Write-Host " ${cC}M${RST} ${cGR}Enter manually instead${RST}"
Write-Host ""
Write-Host " ${cC}$([char]0x25B8)${RST} " -NoNewline
ShowCur
$picked = $false
FlushKeys
while (-not $picked) {
$k = [Console]::ReadKey($true)
if ($k.KeyChar -eq 'm' -or $k.KeyChar -eq 'M') {
Write-Host 'Manual'; HideCur
$sharePath = Prompt-Text 'Enter share path' -Example '\\NEWPC\MigrationShare$' -Required
$picked = $true
}
else {
$numVal = 0
if ([int]::TryParse("$($k.KeyChar)", [ref]$numVal) -and $numVal -ge 1 -and $numVal -le $shares.Count) {
$sharePath = $shares[$numVal - 1].Path
Write-Host $sharePath; HideCur
$picked = $true
}
}
}
}
}
else {
$sharePath = Prompt-Text 'Destination share path' -Example '\\NEWPC\MigrationShare$' -Required
}
# Validate the selected share
Write-Host ""
for ($f = 0; $f -lt 8; $f++) {
[Console]::Write("`r ${cC}$($Spin[$f % $Spin.Count])${RST} ${cGR}Validating share...${RST} ")
Start-Sleep -Milliseconds 60
}
$result = Test-ShareAccess $sharePath
if ($result.OK) {
Write-Host "`r ${cG}$([char]0x2713)${RST} ${cW}$($result.Detail)${RST} "
}
else {
Write-Host "`r ${cR}$([char]0x2717)${RST} ${cR}$($result.Detail)${RST} "
if (-not (Prompt-Confirm 'Continue anyway?')) {
return Show-SharePicker # retry
}
}
return $sharePath
}
# ════════════════════════════════════════════════════════════════
# SCREEN BUILDER (single-buffer → no flicker)
# ════════════════════════════════════════════════════════════════
function Build-MainScreen {
$W = 62; $IW = $W - 2
$b = [System.Text.StringBuilder]::new(4096)
# clear + home
[void]$b.Append("$E[2J$E[H`n")
# ── banner ──
[void]$b.AppendLine(" ${cC}$(Rep ([char]0x2550) $IW)${RST}")
[void]$b.AppendLine(" $(PadC "${BLD}${cY}$([char]0x26A1)${RST} ${BLD}${cW}M I G R A T I O N W I Z A R D R Y${RST} ${BLD}${cY}$([char]0x26A1)${RST}" $IW)")
[void]$b.AppendLine(" $(PadC "${cGR}USMT PC-to-PC User State Migration${RST}" $IW)")
[void]$b.AppendLine(" ${cC}$(Rep ([char]0x2550) $IW)${RST}")
[void]$b.AppendLine()
# ── menu items ──
for ($i = 0; $i -lt $script:Items.Count; $i++) {
$it = $script:Items[$i]
$isSel = ($i -eq $script:Sel)
$isDone = $script:Done.ContainsKey($it.Action)
$arrow = if ($isSel) { "${cC}$([char]0x25B8)${RST}" } else { ' ' }
$marker = if ($isDone) { "${cG}$([char]0x2713)${RST}" } else { "${cGR}$([char]0x25CB)${RST}" }
$num = "${cGR}$($it.Key).${RST}"
$lbl = if ($isSel) { "${BLD}${cW}$($it.Label)${RST}" } else { "${cW}$($it.Label)${RST}" }
$tag = "${cGR}[$($it.Tag)]${RST}"
$left = " $arrow $marker $num $lbl"
$visL = (Strip $left).Length
$gap = [Math]::Max(1, 55 - $visL)
[void]$b.AppendLine("$left$(Rep ' ' $gap)$tag")
if ($i -eq 1) { [void]$b.AppendLine() } # visual break after Capture
}
# ── quit ──
[void]$b.AppendLine(" ${cGR}$(Rep ([char]0x2500) 56)${RST}")
$qSel = ($script:Sel -eq $script:Items.Count)
if ($qSel) {
[void]$b.AppendLine(" ${cC}$([char]0x25B8)${RST} ${BLD}${cW}Q. Quit${RST}")
}
else {
[void]$b.AppendLine(" ${cGR}Q.${RST} ${cW}Quit${RST}")
}
# ── description panel ──
[void]$b.AppendLine()
if ($script:Sel -lt $script:Items.Count) {
$desc = $script:Items[$script:Sel].Desc
$mw = 54
$words = $desc -split ' '; $lines = @(); $cur = ''
foreach ($wd in $words) {
if (($cur.Length + $wd.Length + 1) -gt $mw) { $lines += $cur; $cur = $wd }
else { $cur = if ($cur) { "$cur $wd" }else { $wd } }
}
if ($cur) { $lines += $cur }
[void]$b.AppendLine(" ${cC}$([char]0x250C)$(Rep ([char]0x2500) 56)$([char]0x2510)${RST}")
foreach ($ln in $lines) {
[void]$b.AppendLine(" ${cC}$([char]0x2502)${RST} $(PadR "${cGR}$ln${RST}" 55)${cC}$([char]0x2502)${RST}")
}
[void]$b.AppendLine(" ${cC}$([char]0x2514)$(Rep ([char]0x2500) 56)$([char]0x2518)${RST}")
}
# ── status bar ──
[void]$b.AppendLine()
[void]$b.Append(" ${cGR}$([char]0x2191)$([char]0x2193)${RST} ${cW}Navigate${RST} ${cGR}$([char]0x00B7)${RST} ${cGR}Enter${RST} ${cW}Select${RST} ${cGR}$([char]0x00B7)${RST} ${cGR}Q${RST} ${cW}Quit${RST}")
return $b.ToString()
}
# ════════════════════════════════════════════════════════════════
# INPUT
# ════════════════════════════════════════════════════════════════
function Read-MenuChoice {
FlushKeys
while ($true) {
$k = [Console]::ReadKey($true)
switch ($k.Key) {
'UpArrow' { $script:Sel = ($script:Sel - 1 + $script:TotalChoices) % $script:TotalChoices; [Console]::Write((Build-MainScreen)) }
'DownArrow' { $script:Sel = ($script:Sel + 1) % $script:TotalChoices; [Console]::Write((Build-MainScreen)) }
'Enter' {
if ($script:Sel -eq $script:Items.Count) { return 'Quit' }
return $script:Items[$script:Sel].Action
}
default {
$ch = $k.KeyChar
if ($ch -eq 'q' -or $ch -eq 'Q') { return 'Quit' }
$m = $script:Items | Where-Object { $_.Key -eq "$ch" }
if ($m) { return $m.Action }
}
}
}
}
function Prompt-Text([string]$Label, [string]$Default = '', [string]$Example = '', [switch]$Required) {
ShowCur
Write-Host " ${BLD}${cW}${Label}${RST}"
if ($Example) { Write-Host " ${cGR}Example: $Example${RST}" }
$hint = if ($Default) { "${cGR}[$Default]${RST} " } else { '' }
Write-Host " ${cC}$([char]0x25B8)${RST} $hint" -NoNewline
$val = Read-Host
if (-not $val -and $Default) { $val = $Default }
if ($Required -and -not $val) {
Write-Host " ${cR}Required.${RST}"; return Prompt-Text $Label $Default $Example -Required:$Required
}
HideCur; return $val
}
function Prompt-Toggle([string]$Label, [bool]$Default = $false) {
$opts = if ($Default) { "[${cG}Y${RST}/n]" }else { "[y/${cG}N${RST}]" }
Write-Host " ${cW}$Label${RST} $opts " -NoNewline
ShowCur
$k = WaitKey
# switch is case-insensitive by default — duplicate branches cause array return!
$r = switch ($k.KeyChar) { 'y' { $true } 'n' { $false } default { $Default } }
if ($r) {
Write-Host "${cG}Yes $([char]0x2713)${RST}"
}
else {
Write-Host "${cW}No ${cR}$([char]0x2717)${RST}"
}
HideCur; return $r
}
function Prompt-Confirm([string]$Msg, [switch]$DefaultYes) {
Write-Host ""
if ($DefaultYes) {
$opts = "[${cG}Y${RST}/n]"
}
else {
$opts = "[y/${cG}N${RST}]"
}
Write-Host " ${BLD}${cY}?${RST} ${cW}$Msg${RST} $opts " -NoNewline
ShowCur
$k = WaitKey
if ($DefaultYes) {
$r = $k.KeyChar -ne 'n' -and $k.KeyChar -ne 'N'
}
else {
$r = $k.KeyChar -eq 'y' -or $k.KeyChar -eq 'Y'
}
if ($r) {
Write-Host "${cG}Yes $([char]0x2713)${RST}"
}
else {
Write-Host "${BLD}${cR}No $([char]0x2717)${RST}"
}
HideCur; return $r
}
function Wait-AnyKey {
Write-Host ""
Write-Host " ${cGR}Press any key to return to menu...${RST}"
ShowCur; [void](WaitKey); HideCur
}
# ════════════════════════════════════════════════════════════════
# STEP HEADER & RESULT BANNERS
# ════════════════════════════════════════════════════════════════
function Show-StepHeader([string]$Title, [string]$Sub = '') {
[Console]::Write("$E[2J$E[H"); HideCur
$W = 62; $IW = $W - 2
Write-Host ""
Write-Host " ${cC}$(Rep ([char]0x2550) $IW)${RST}"
Write-Host " $(PadC "${BLD}${cW}$Title${RST}" $IW)"
if ($Sub) { Write-Host " $(PadC "${cGR}$Sub${RST}" $IW)" }
Write-Host " ${cC}$(Rep ([char]0x2550) $IW)${RST}"
}
function Show-ResultBanner([bool]$Ok, [string]$Msg) {
try {
# Truncate long messages to fit the 56-char box
if ($Msg.Length -gt 50) { $Msg = $Msg.Substring(0, 47) + '...' }
$icon = if ($Ok) { "$([char]0x2713)" }else { "$([char]0x2717)" }
$col = if ($Ok) { $cG }else { $cR }
Write-Host ""
Write-Host " ${cGR}$(Rep ([char]0x2500) 58)${RST}"
Write-Host ""
Write-Host " ${col}$([char]0x250C)$(Rep ([char]0x2500) 56)$([char]0x2510)${RST}"
# Build the inner text without nesting ANSI in PadC — pad manually
$inner = "$icon $Msg"
$pad = [Math]::Max(0, 54 - $inner.Length)
$lp = [Math]::Floor($pad / 2); $rp = $pad - $lp
Write-Host " ${col}$([char]0x2502)${RST} $(Rep ' ' $lp)${BLD}${col}${inner}${RST}$(Rep ' ' $rp) ${col}$([char]0x2502)${RST}"
Write-Host " ${col}$([char]0x2514)$(Rep ([char]0x2500) 56)$([char]0x2518)${RST}"
}
catch {
# Fallback if anything goes wrong with rendering
Write-Host ""
if ($Ok) { Write-Host " ${cG}$([char]0x2713) $Msg${RST}" }
else { Write-Host " ${cR}$([char]0x2717) $Msg${RST}" }
}
}
function Show-Summary([System.Collections.Specialized.OrderedDictionary]$Fields) {
Write-Host ""
Write-Host " ${BLD}${cW}Configuration${RST}"
Write-Host " ${cGR}$(Rep ([char]0x2500) 46)${RST}"
foreach ($k in $Fields.Keys) {
Write-Host " $(PadR "${cGR}${k}:${RST}" 24) ${cW}$($Fields[$k])${RST}"
}
}
# ════════════════════════════════════════════════════════════════
# EXECUTE STEP (child process + title-bar spinner)
# ════════════════════════════════════════════════════════════════
function Invoke-Step([string]$Label, [string]$Script, [string]$ParamBlock) {
$tmp = Join-Path $env:TEMP "mw-run-$([System.IO.Path]::GetRandomFileName()).ps1"
$fullScript = Join-Path $script:ScriptsDir $Script
$body = @"
`$ErrorActionPreference = 'Continue'
& '$($fullScript -replace "'","''")' $ParamBlock
exit `$LASTEXITCODE
"@
[System.IO.File]::WriteAllText($tmp, $body, [System.Text.Encoding]::UTF8)
Write-Host ""
Write-Host " ${cC}$([char]0x2501)$([char]0x2501)$([char]0x2501)${RST} ${cW}$Label${RST} ${cC}$([char]0x2501)$([char]0x2501)$([char]0x2501)${RST}"
Write-Host ""
# Brief launch spinner
for ($f = 0; $f -lt 8; $f++) {
$s = $Spin[$f % $Spin.Count]
[Console]::Write("`r ${cC}$s${RST} ${cGR}Launching...${RST} ")
Start-Sleep -Milliseconds 60
}
Write-Host "`r ${cG}$([char]0x2713)${RST} ${cW}Running${RST} "
Write-Host ""
# Shared console — child output renders directly (preserves progress bars + Unicode)
ShowCur
$psi = [System.Diagnostics.ProcessStartInfo]::new()
$psi.FileName = 'powershell.exe'
$psi.Arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$tmp`""
$psi.WorkingDirectory = if ($script:IsUNC) { $env:SystemRoot } else { $script:ScriptRoot }
$psi.UseShellExecute = $false
$psi.CreateNoWindow = $false
$proc = [System.Diagnostics.Process]::Start($psi)
# Title bar spinner + WT tab progress indicator while child runs
$frame = 0; $t0 = Get-Date
while (-not $proc.HasExited) {
$el = ((Get-Date) - $t0).ToString('mm\:ss')
$s = $Spin[$frame % $Spin.Count]
$host.UI.RawUI.WindowTitle = "$s $Label [$el]"
# Windows Terminal tab progress (indeterminate spinner)
[Console]::Write("$E]9;4;3;0$E\")
$frame++
Start-Sleep -Milliseconds 80
}
# Clear WT progress + show elapsed
[Console]::Write("$E]9;4;0;0$E\")
$ec = $proc.ExitCode
$elapsed = ((Get-Date) - $t0).ToString('mm\:ss')
Write-Host ""
Write-Host " ${cG}$([char]0x2713)${RST} ${cW}Done${RST} ${cGR}[$elapsed]${RST}"
$host.UI.RawUI.WindowTitle = 'MigrationMerlin'
HideCur
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
return ($ec -eq 0)
}
# ════════════════════════════════════════════════════════════════
# USMT PRE-CHECK
# ════════════════════════════════════════════════════════════════
function Find-USMT([string]$CustomPath) {
<# Check if USMT (scanstate/loadstate) is reachable. Returns @{ Found; Path; Detail }. #>
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' }
elseif ([Environment]::Is64BitOperatingSystem) { 'amd64' }
else { 'x86' }
$candidates = @()
if ($CustomPath) { $candidates += $CustomPath }
$candidates += @(
(Join-Path $script:ScriptRoot 'USMT-Tools')
(Join-Path $env:TEMP 'USMT-Tools')
"${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\User State Migration Tool"
"${env:ProgramFiles}\Windows Kits\10\Assessment and Deployment Kit\User State Migration Tool"
'C:\USMT'
'C:\Tools\USMT'
)
foreach ($base in $candidates) {
if (-not (Test-Path $base -ErrorAction SilentlyContinue)) { continue }
# Try: arch subfolder → arm64 fallback → flat folder
$tryPaths = @((Join-Path $base $arch))
if ($arch -eq 'arm64') { $tryPaths += (Join-Path $base 'amd64') }
$tryPaths += $base
foreach ($tp in $tryPaths) {
$exe = Join-Path $tp 'scanstate.exe'
if (-not (Test-Path $exe -ErrorAction SilentlyContinue)) { continue }
# Verify binary is compatible with this OS
try {
$null = & $exe /? 2>&1
return [pscustomobject]@{ Found = $true; Path = $tp; Detail = "scanstate.exe verified in $tp" }
}
catch {
$errMsg = "$_"
if ($errMsg -match 'compat|machine type|version') {
# Binary exists but wrong arch — keep searching
continue
}
# Other error (permissions etc) — still usable
return [pscustomobject]@{ Found = $true; Path = $tp; Detail = "scanstate.exe found in $tp (not verified: $errMsg)" }
}
}
}
# Check for bundled zip (scripts will extract it at runtime)
$zipSearchPaths = @(
(Join-Path $script:ScriptRoot 'user-state-migration-tool.zip')
(Join-Path (Split-Path $script:ScriptRoot -Parent -ErrorAction SilentlyContinue) 'user-state-migration-tool.zip')
(Join-Path $env:TEMP 'user-state-migration-tool.zip')
)
foreach ($zp in $zipSearchPaths) {
if ($zp -and (Test-Path $zp -ErrorAction SilentlyContinue)) {
$sizeMB = [Math]::Round((Get-Item $zp).Length / 1MB, 1)
return [pscustomobject]@{ Found = $true; Path = "ZIP: $zp"; Detail = "Bundled zip found ($sizeMB MB) - will extract at runtime" }
}
}
return [pscustomobject]@{ Found = $false; Path = ''; Detail = 'USMT not found (no scanstate.exe, no bundled zip, no ADK)' }
}
function Show-USMTCheck([string]$CustomPath) {
<# Run USMT check with spinner, show result, offer options if missing. Returns USMTPath string (empty = auto). #>
Write-Host ""
for ($f = 0; $f -lt 6; $f++) {
[Console]::Write("`r ${cC}$($Spin[$f % $Spin.Count])${RST} ${cGR}Checking for USMT...${RST} ")
Start-Sleep -Milliseconds 50
}
$result = Find-USMT $CustomPath
if ($result.Found) {
Write-Host "`r ${cG}$([char]0x2713)${RST} ${cW}$($result.Detail)${RST} "
return $CustomPath
}
Write-Host "`r ${cR}$([char]0x2717)${RST} ${cR}$($result.Detail)${RST}"
Write-Host ""
Write-Host " ${cY}USMT is required for migration. Options:${RST}"
Write-Host " ${cW}1.${RST} ${cGR}Install Windows ADK with USMT component${RST}"
Write-Host " ${cW}2.${RST} ${cGR}Copy the bundled zip (user-state-migration-tool.zip) to this PC${RST}"
Write-Host " ${cW}3.${RST} ${cGR}Specify a custom USMT path below${RST}"
Write-Host " ${cGR} ADK download: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install${RST}"
Write-Host ""
$uPath = Prompt-Text 'Custom USMT path (blank to let the script try auto-install)'
return $uPath
}
# ════════════════════════════════════════════════════════════════
# INLINE VALIDATION
# ════════════════════════════════════════════════════════════════
function Validate-Inline([string]$Label, [scriptblock]$Check) {
<# Run a quick check and show pass/fail inline. Returns $true/$false. #>
for ($f = 0; $f -lt 6; $f++) {
[Console]::Write("`r ${cC}$($Spin[$f % $Spin.Count])${RST} ${cGR}$Label${RST} ")
Start-Sleep -Milliseconds 50
}
$ok = & $Check
if ($ok) {
Write-Host "`r ${cG}$([char]0x2713)${RST} ${cW}$Label${RST} "
}
else {
Write-Host "`r ${cR}$([char]0x2717)${RST} ${cR}$Label${RST} "
}
return $ok
}
# ════════════════════════════════════════════════════════════════
# INTERACTIVE USER PICKER
# ════════════════════════════════════════════════════════════════
function Show-UserPicker {
<# Arrow-key checkbox picker for local user profiles. Returns hashtable with Include/Exclude strings. #>
Write-Host ""
Write-Host " ${BLD}${cW}User Selection${RST}"
Write-Host " ${cGR}$(Rep ([char]0x2500) 40)${RST}"
Write-Host " ${cC}I${RST} ${cW}Interactive${RST} (pick from system users)"
Write-Host " ${cC}M${RST} ${cW}Manual entry${RST} (comma-separated)"
Write-Host " ${cC}A${RST} ${cW}All users${RST} (default)"
Write-Host ""
Write-Host " ${cC}$([char]0x25B8)${RST} " -NoNewline
ShowCur
$mode = $null
FlushKeys
while ($null -eq $mode) {
$k = [Console]::ReadKey($true)
switch -regex ("$($k.KeyChar)") {
'[iI]' { Write-Host 'Interactive'; HideCur; $mode = 'interactive' }
'[mM]' { Write-Host 'Manual'; HideCur; $mode = 'manual' }
'[aA]' { Write-Host 'All users'; HideCur; return @{ Include = ''; Exclude = '' } }
default {
if ($k.Key -eq 'Enter') { Write-Host 'All users'; HideCur; return @{ Include = ''; Exclude = '' } }
}
}
}
if ($mode -eq 'manual') {
$inc = Prompt-Text 'Include users (comma-separated, blank for all)'
$exc = Prompt-Text 'Exclude users (comma-separated, blank for none)'
return @{ Include = $inc; Exclude = $exc }
}
# ── Interactive mode: enumerate profiles ──
Write-Host ""
$profiles = @()
try {
$wpList = Get-CimInstance Win32_UserProfile -ErrorAction Stop |
Where-Object { -not $_.Special -and $_.LocalPath }
foreach ($wp in $wpList) {
$short = Split-Path $wp.LocalPath -Leaf
$display = $short
try {
$display = (New-Object System.Security.Principal.SecurityIdentifier($wp.SID)).Translate(
[System.Security.Principal.NTAccount]).Value
}
catch {}
$profiles += [pscustomobject]@{
Display = $display
Short = $short
Path = $wp.LocalPath
Selected = $true
}
}
}
catch {
Write-Host " ${cY}$([char]0x26A0) Could not enumerate users. Falling back to manual entry.${RST}"
$inc = Prompt-Text 'Include users (comma-separated, blank for all)'
$exc = Prompt-Text 'Exclude users (comma-separated, blank for none)'
return @{ Include = $inc; Exclude = $exc }
}
if ($profiles.Count -eq 0) {
Write-Host " ${cY}$([char]0x26A0) No user profiles found.${RST}"
return @{ Include = ''; Exclude = '' }
}
# Render the checkbox list using ANSI cursor-up for re-render (SetCursorPosition is unreliable in WT)
$script:ulProfiles = $profiles
$script:ulIdx = 0
$script:ulFirstRender = $true
# Cursor is ON the hint line, so go up (profiles + 1 blank) = profiles+1 lines to reach line 0
$script:ulTotalLines = $profiles.Count + 1
function Render-UserList {
# On re-render: move cursor up to overwrite previous list
if (-not $script:ulFirstRender) {
[Console]::Write("$E[$($script:ulTotalLines)A`r")
}
$script:ulFirstRender = $false
$buf = [System.Text.StringBuilder]::new(1024)
for ($i = 0; $i -lt $script:ulProfiles.Count; $i++) {
$p = $script:ulProfiles[$i]
$arrow = if ($i -eq $script:ulIdx) { "${cC}$([char]0x25B8)${RST}" } else { ' ' }
$check = if ($p.Selected) { "${cG}$([char]0x2713)${RST}" } else { "${cGR}$([char]0x25CB)${RST}" }
$lbl = if ($i -eq $script:ulIdx) { "${BLD}${cW}$($p.Display)${RST}" } else { "${cW}$($p.Display)${RST}" }
$path = "${cGR}$($p.Path)${RST}"
[void]$buf.AppendLine(" $arrow [$check] $(PadR $lbl 28) $path ")
}
[void]$buf.AppendLine()
[void]$buf.Append(" ${cGR}$([char]0x2191)$([char]0x2193)${RST} Navigate ${cGR}T${RST} Toggle ${cGR}A${RST} All ${cGR}N${RST} None ${cGR}Enter${RST} Done")
[Console]::Write($buf.ToString())
}
Render-UserList
HideCur
FlushKeys
$done = $false
while (-not $done) {
$k = [Console]::ReadKey($true)
switch ($k.Key) {
'UpArrow' { $script:ulIdx = ($script:ulIdx - 1 + $script:ulProfiles.Count) % $script:ulProfiles.Count }
'DownArrow' { $script:ulIdx = ($script:ulIdx + 1) % $script:ulProfiles.Count }
'Enter' { $done = $true; continue }
default {
switch ($k.KeyChar) {
't' { $script:ulProfiles[$script:ulIdx].Selected = -not $script:ulProfiles[$script:ulIdx].Selected }
'a' { $script:ulProfiles | ForEach-Object { $_.Selected = $true } }
'n' { $script:ulProfiles | ForEach-Object { $_.Selected = $false } }
}
}
}
if (-not $done) { Render-UserList }
}
$selected = @($script:ulProfiles | Where-Object { $_.Selected } | ForEach-Object { $_.Short })
$excluded = @($script:ulProfiles | Where-Object { -not $_.Selected } | ForEach-Object { $_.Short })
$total = $script:ulProfiles.Count
Write-Host ""
if ($excluded.Count -eq 0) {
Write-Host " ${cG}$([char]0x2713)${RST} ${cW}All $total users selected${RST}"
}
else {
Write-Host " ${cG}$([char]0x2713)${RST} ${cW}$($selected.Count) of $total users selected${RST}"
}
# Build include/exclude strings
$incStr = if ($excluded.Count -eq 0) { '' } else { $selected -join ',' }
$excStr = $excluded -join ','
return @{ Include = $incStr; Exclude = $excStr }
}
# ════════════════════════════════════════════════════════════════
# STEP WORKFLOWS
# ════════════════════════════════════════════════════════════════
# ── 1. Setup Destination ──────────────────────────────────────
function Step-Setup {
:setupLoop while ($true) {
Show-StepHeader 'STEP 1: SETUP DESTINATION' 'Run this on the NEW PC'
$cfg = Show-ConfigPrompt 'setup'
Write-Host ""
$defFolder = if ($cfg) { $cfg.Folder } else { 'C:\MigrationStore' }
$defShare = if ($cfg) { $cfg.Share } else { 'MigrationShare$' }
$defIP = if ($cfg) { $cfg.SourceIP } else { '' }
$folder = Prompt-Text 'Migration folder path' -Default $defFolder
$parentDir = Split-Path $folder -Parent
if ($parentDir -and -not (Test-Path $parentDir -ErrorAction SilentlyContinue)) {
Write-Host " ${cY}$([char]0x26A0) Parent directory '$parentDir' does not exist (will be created)${RST}"
}
elseif (Test-Path $folder -ErrorAction SilentlyContinue) {
Write-Host " ${cG}$([char]0x2713)${RST} ${cGR}Folder already exists${RST}"
}
$share = Prompt-Text 'Share name' -Default 'MigrationShare$'
if ($share -match '[\\/:*?"<>|]') {
Write-Host " ${cR}$([char]0x2717) Invalid characters in share name${RST}"
if (-not (Prompt-Confirm 'Continue anyway?')) { continue setupLoop }
}
$srcIP = Prompt-Text 'Restrict to source IP (optional, Enter to skip)' -Example '192.168.1.100'
if ($srcIP -and $srcIP -notmatch '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') {
Write-Host " ${cY}$([char]0x26A0) Does not look like a valid IPv4 address${RST}"
if (-not (Prompt-Confirm 'Continue anyway?')) { continue setupLoop }
}
$skipUSMT = Prompt-Toggle 'Skip USMT install? (if already installed)'
# ── USMT pre-check ──
$usmtPath = ''
if (-not $skipUSMT) {
$usmtPath = Show-USMTCheck ''
}
# ── Disk space check ──
$drive = Split-Path $folder -Qualifier -ErrorAction SilentlyContinue
if ($drive) {
try {
$freeGB = [Math]::Round((Get-PSDrive ($drive -replace ':') -ErrorAction Stop).Free / 1GB, 1)
Write-Host " ${cGR}Free space on $($drive) $($freeGB) GB${RST}"
if ($freeGB -lt 5) {
Write-Host " ${cY}$([char]0x26A0) Less than 5 GB free${RST}"
}
}