-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreTools.ps1
More file actions
5491 lines (4575 loc) · 268 KB
/
CoreTools.ps1
File metadata and controls
5491 lines (4575 loc) · 268 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
# This script automates Windows post-installation setup, including system performance
# optimizations, telemetry removal, and the automated deployment of development
# tools via Winget and Chocolatey.
# KEY FEATURES:
# 1. Session Setup: Configures execution policy to [Bypass] for the current process.
# 2. Legacy Cleanup: Silently scans and removes old CMD/PowerShell registry entries if present.
# 3. Context Menus: Adds multi-language CMD & PowerShell prompts (Shift + Right-click) with UNC path support.
# 4. Advanced Desktop Tools: Adds a categorized menu for Control Panel, Safe Mode, Task Killer, and Explorer Restart.
# 5. Boot Optimization: Procedural BCD/Registry fix to uncheck 'Number of Processors' in MSConfig to prevent instability and thermal throttling.
# 6. System Performance: Enables automatic Pagefile management and removes QoS bandwidth limits.
# 7. Explorer Tweaks: Hides Desktop Recycle Bin and pins it to the Explorer Sidebar for a cleaner workspace.
# 8. Visuals & Login: Sets 100% Wallpaper quality, enables NumLock on login, and synchronizes SecPol for No-CTRL+ALT+DEL.
# 9. File Handling: Restores 'New Text Document' and Script templates (.ps1, .reg, .bat, vbs, cmd) to the context menu.
# 10. Windows Updates: Hard-disables forced Driver updates and Microsoft's monthly bloatware "gift"—the useless Malicious Software Removal Tool (MRT).
# 11. SvcHost Optimization: Implements dynamic RAM-based SvcHost grouping (Split Threshold) to reduce process overhead.
# 12. App Management: Disables Background Apps globally to save CPU/RAM.
# 13. Update Freeze: Hard-pauses Windows Updates until the year 3000.
# 14. Version-Specific: Adds 'Check Ownership' menu (for Windows 26H1+ / non-25H2).
# 15. Universal Take Ownership: Deploys a 22-language "Take Ownership" menu using a high-compatibility .reg import method with orange checkmark icons.
# 16. Power Management: Disables network connectivity during Modern Standby (AC) to prevent "Sleep-to-Wake" drain.
# 17. Telemetry & Gaming: Disables Mouse acceleration, Office/PS telemetry, and Game Bar.
# 18. OneDrive removal: Deep uninstallation with data migration and 5s timeout.
# 19. Core Package Managers: Automated install/update of Chocolatey, Winget, and PS7.
# 20. Software Deployment: Installs dev tools and utilities via Choco (with Python/Dart pathing).
# 21. Optional Scripts: Digital Entitlement (MAS) and StartAllBack blocker with 5s skip.
# 22. Registry Fixes: Alt+Tab (Show 20 Edge Tabs), Explorer starts at 'This PC', and No Auto-Reboot.
# 23. Context Limit: Increases the right-click "Multiple Files" selection limit to 128 items.
# 24. Shell Folders: Restores all User Folders (Downloads, Documents, etc.) directly under 'This PC'.
# 25. Browser Debloat: Disables Telemetry, AI (Copilot/Leo), and Bloat for Chrome, Brave, Edge & Firefox.
# 26. Network/DNS: Optimizes DNS Cache TTL and table size for faster web resolution.
# 27. Python Ecosystem: Automated pip upgrade and Hugging Face CLI (HF-CLI) deployment.
# 28. Startup Manager: Disables Steam, Discord, Teams, and others via binary status (03) in Registry.
# 29. Winget Deployment: Interactive setup for Communication, Security, and AI tools via Store IDs with 5s popups.
# 30. Gaming Essentials: One-click pack (Steam, Discord, EA, Epic, Xbox) with automated Store ID matching.
# 31. GitHub Env: Sets NTFS protection to false and enables Case Sensitivity on specialized development folders.
# 32. Git Optimization: Migrates Git Bash and Git GUI context menu items to 'Shift + Right Click' to reduce clutter.
# 33. User Security: Force-sets 'Password Never Expires' for the Admin account.
# 34. Crash Analysis: Enables Detailed BSOD (DisplayParameters) for technical info.
# 35. Print Spooler ACL: Universal SID (S-1-1-0) Full Control grant for 'Everyone'.
# 36. Spooler Context Menu: 22-language repair tool deployed to C:\Windows.
# 37. Visual Effects: Enforced "Show thumbnails" and "Desktop icon shadows".
# 38. Media Extensions: Auto-update for HEVC (Free-Codecs) and 8 Codecs extensions.
# 39. Advanced Thumbnailing: Automated GitHub deployment for Icaros Thumbnailer.
# 40. Context Menu Purge: High-speed registry cleanup to remove grepWin shell entries using native reg.exe for zero-lag execution.
# 41. Explorer UI Opt: Windows 11-specific Snap Layouts enablement and smart Quick Access management. Disables automatic frequent folders and provides an interactive 5s prompt to clear cache only if requested, preserving manual pins.
# 42. Start Menu Refactor: Automated renaming of 'XTools' to 'Tools' with recursive cleanup of redundant PhoenixOS shortcuts and folders.
# 43. Volume Identity: Force-sets System Drive (C:) label to "Windows" and purges localized "Extras + Info" desktop clutter.
# 44. JUNKWARE PURGE: Interactive 5s skip-prompt to remove "Digital Parasites" (McAfee, Norton, AVG, Kaspersky) using official manufacturer removal tools.
# 45. DEFENDER LOBOTOMY: High-level Registry/Policy injection to completely disable Windows Defender, Tamper Protection, and Kernel Mitigations, eliminating useless background overhead and restoring absolute system control.
# 46. WINDOWS AI PURGE: Safe-Mode removal of Copilot, Recall, and AI background services via registry, policies, and Appx removal with a 5s interactive prompt.
# 47. EDGE EXORCISM: Deep uninstallation of Microsoft Edge using native setup.exe flags, including a registry "dummy" lock to prevent silent re-installation.
# 48. NOTEPAD CLASSIC RESTORATION: Automated detection and removal of the modern UWP Notepad (9MSMLRH6LZF3) to eliminate AI "Rewrite" bloat and restore system leaness.
# 49. Precision Time Protocol (NTP) Optimization: Swaps default Windows time server for the global pool.ntp.org cluster to ensure lower latency and better sync reliability.
# 50. PowerShell Downgrade Protection: Blocks the legacy PowerShell 2.0 engine using SecEdit-based ACL resets to mitigate downgrade attacks.
# 51. SMBv1 Deactivation: Direct Registry enforcement to disable the insecure SMBv1 protocol, preventing ransomware (WannaCry style) propagation.
# 52. Connectivity Restoration (TLS/SChannel): Comprehensive reset of SCHANNEL settings, insecure ciphers (RC4/DES), and weak hashes (MD5) to restore compatibility with modern web portals, tax services (NFe), and .NET apps.
# 53. System & OEM Intelligence: Implements a deep-scan hardware module that detects Computer Type (Mobile, Desktop, or VM) and System Manufacturer (DMI). It executes a conditional logic to update Windows OEM Information, ensuring a professional system identity by combining Manufacturer and Model for physical PCs while maintaining raw DMI data for Servers and Virtual Machines.
# 54. Vanguard & Valorant Toolkit: Dual-purpose module that validates Riot Vanguard requirements (TPM 2.0, Secure Boot, HVCI) with auto-fix capabilities, and provides a "Nuclear Emergency" repair tool to wipe corrupted vgk.sys drivers and services in Safe Mode to resolve KERNEL_SECURITY_CHECK_FAILURE (0x139) loops.
# 55. BitLocker Privacy & Performance Hardening: Implements a multi-layered shield to disable automatic encryption, block insecure hardware-based encryption, and force-decrypt all volumes to restore SSD performance and data sovereignty.
# 56. SmartScreen Professional Audit: Comprehensive disabling of reputation-based filters for Explorer, Edge, and the Microsoft Store. Eliminates false positives on custom scripts, prevents file-metadata telemetry to Microsoft, and removes "Potentially Unwanted App" (PUA) blocking to restore administrative flow.
# 57. Microsoft Activation Status Professional Audit: A deep-audit module that identifies the exact edition, licensing channel (Retail, OEM, KMS, MAK), and permanency status for Windows, Office, Project, and Visio, featuring native console color-bleed correction.
# 58. Microsoft License Management Tool: An interactive command interface with a 5-second timeout for installing new Windows product keys, performing deep license registry cleanups (slmgr), and purging blocked Office key fragments via OSPP to resolve activation conflicts.
# 59. Disk Intelligence & SMART Analysis Module: A high-performance diagnostic engine that performs real-time parsing of CrystalDiskInfo logs to extract critical metrics including drive health, temperature, firmware status, power-on hours, and host read/write counters, featuring a multi-language adaptive UI layer with structured output formatting.
# 60. SSD Longevity & Performance Optimizer: A deterministic SSD tuning framework designed to maximize NAND lifespan and reduce unnecessary write amplification. Implements controlled system behavior adjustments including kernel-level paging strategy, TRIM enforcement, flush policy optimization, and telemetry reduction, while preserving OS stability and update compatibility.
# --- APPENDIX: LEGACY EXECUTION POLICY SETTINGS (DISABLED) ---
# The following section is kept for reference only.
# Current logic uses '-Scope Process' to avoid permanent system changes.
<#
# --- Original Execution Policy Setup ---
# This was used to set 'Unrestricted' policy for the CurrentUser.
# Write-Host "Setting PowerShell execution policy to Unrestricted for the current user..."
# Set-ExecutionPolicy -Scope CurrentUser Unrestricted -Force >$null 2>&1
# --- Original Revert Logic ---
# This was used at the end of the script to restore policy to RemoteSigned.
# Write-Host "Reverting PowerShell execution policy to RemoteSigned for current user..."
# Set-ExecutionPolicy -Scope CurrentUser RemoteSigned -Force >$null 2>&1
# Write-Host "Execution policy set to RemoteSigned for current user."
# Write-Host "Software setup and installation completed successfully! ✅"
#>
# --------------------------------------------------------------
# --- 0. Setup: Ensure Execution Policy is permissive for this session ---
Write-Host "Configuring session execution policy..." -ForegroundColor Cyan
# Using -Scope Process ensures it only affects this current session
# and doesn't trigger GPO/Administrator overrides or warnings.
try {
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force | Out-Null
Write-Host "Execution policy set to [Bypass] for current session. ✅" -ForegroundColor Green
} catch {
Write-Host "Warning: Could not set execution policy, but continuing..." -ForegroundColor Yellow
}
# Gets the directory where this script (.ps1) is being executed.
# $PSScriptRoot is an automatic PowerShell variable that holds the full path of the current script's directory.
$scriptDir = $PSScriptRoot
##------------------------------------------------------##
# Clear
Clear-Host
if (Test-Path ($h = "$HOME\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt")) { Remove-Item $h -Force -ErrorAction SilentlyContinue }
# LIGHTNING - ASCII ART
Write-Host " ,/" -ForegroundColor Yellow
Write-Host " ,'/" -ForegroundColor Yellow
Write-Host " ,' /" -ForegroundColor Yellow
Write-Host " ,' /_____," -ForegroundColor Yellow
Write-Host " .'____ ,' " -ForegroundColor Yellow
Write-Host " / ,' " -ForegroundColor Yellow
Write-Host " / ,' " -ForegroundColor Yellow
Write-Host " /,' " -ForegroundColor Yellow
Write-Host " /' " -ForegroundColor Yellow
Write-Host " ______________________________________" -ForegroundColor Gray
Write-Host " >> ⚡ WORKSTATION TOOLS " -ForegroundColor Cyan -NoNewline
Write-Host "" -ForegroundColor DarkGray
Write-Host " >> Developed by TogoFire " -ForegroundColor Magenta
Write-Host " ______________________________________" -ForegroundColor Gray
Write-Host ""
##------------------------------------------------------##
# --- ADMIN PRIVILEGES CHECK ---
# Ensures the script is running with elevated permissions before proceeding.
# Checks if the current user is NOT running PowerShell with Administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# Displays an error message in red if Admin permissions are missing
Write-Host "[!] ERROR: Admin privileges required." -ForegroundColor Red;
# Terminates script execution immediately to prevent "Access Denied" errors
exit
}
##------------------------------------------------------##
# --- SYSTEM INFORMATION & OEM UPDATER ---
Write-Host "-- Gathering System Information..." -ForegroundColor Cyan
# 1. Gathering Data
$computerSystem = Get-CimInstance Win32_ComputerSystem
$chassis = Get-CimInstance Win32_SystemEnclosure
$os = Get-CimInstance Win32_OperatingSystem
$bios = Get-CimInstance Win32_BIOS
$processor = Get-CimInstance Win32_Processor
$gpus = Get-CimInstance Win32_VideoController
# 2. Advanced Computer Type Detection (Mobile/Desktop/VM)
$chassisType = switch ($chassis.ChassisTypes) {
{ $_ -in 8, 9, 10, 11, 12, 14, 30, 31, 32 } { "Mobile" }
{ $_ -in 3, 4, 5, 6, 7, 15, 16 } { "Desktop" }
default { "Workstation" }
}
# Virtual Machine & Server check
$isVM = $computerSystem.Model -match "Virtual|VMware|VirtualBox|Hyper-V"
$isServer = $os.Caption -match "Server"
if ($isVM) { $chassisType = "Virtual Machine" }
$computerFullModel = "$($computerSystem.Manufacturer) $($computerSystem.Model) ($chassisType)"
# 3. OS & Kernel Details
$osVersion = $os.Version
$architecture = $os.OSArchitecture
$displayVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").DisplayVersion
# 4. Chipset Detection
$chipsetInfo = Get-CimInstance Win32_PnPEntity | Where-Object { $_.Caption -match "Chipset|Host Bridge|DRAM Controller" } | Select-Object -First 1 -ExpandProperty Caption
if (-not $chipsetInfo) { $chipsetInfo = "Standard System Chipset" }
# 5. Hardware DirectX Support
$dxCapability = "DirectX 9.0"
$gpuMaxLevel = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Direct3D\Drivers" -ErrorAction SilentlyContinue).MaxFeatureLevel
if ($null -eq $gpuMaxLevel) {
if (Test-Path "C:\Windows\System32\d3d12.dll") { $dxCapability = "DirectX 12" }
elseif (Test-Path "C:\Windows\System32\d3d11.dll") { $dxCapability = "DirectX 11" }
} else {
if ($gpuMaxLevel -ge 0xc000) { $dxCapability = "DirectX 12" }
elseif ($gpuMaxLevel -ge 0xb000) { $dxCapability = "DirectX 11" }
else { $dxCapability = "DirectX 10" }
}
# 6. RAM Details
$ramModules = Get-CimInstance Win32_PhysicalMemory
$ramTotalGB = [math]::Round($computerSystem.TotalPhysicalMemory / 1GB)
$ramSpeed = if ($ramModules) { ($ramModules | Measure-Object -Property ConfiguredClockSpeed -Maximum).Maximum } else { 0 }
$smbiosMemory = $ramModules | Select-Object -First 1
$memoryType = switch ($smbiosMemory.SMBIOSMemoryType) {
20 { "DDR" } 21 { "DDR2" } 24 { "DDR3" } 26 { "DDR4" } 34 { "DDR5" } default { "DDR" }
}
# 7. HARDCORE MONITOR DETECTION (Registry Deep Scan)
$monitorInfo = "Generic PnP Monitor"
try {
$monList = Get-PnpDevice -Class Monitor -Status OK -ErrorAction SilentlyContinue
if ($monList) {
$activeMon = $monList[0]
$hwID = ($activeMon.HardwareID | Where-Object { $_ -match "MONITOR\\" }) -replace "MONITOR\\", ""
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\DISPLAY\$($activeMon.InstanceId.Split('\')[1])"
$subKey = Get-ChildItem $regPath -ErrorAction SilentlyContinue | Select-Object -First 1
$driverDesc = Get-ItemPropertyValue $subKey.PSPath -Name "DeviceDesc" -ErrorAction SilentlyContinue
$cleanName = if ($driverDesc -match ";(.+)") { $matches[1] } else { $driverDesc }
$mfgPrefix = if ($hwID -match "^BOE") { "BOEhydis" } else { "" }
if ($cleanName -and $cleanName -notmatch "Generic|Integrated") {
$monitorInfo = "$mfgPrefix $cleanName ($hwID)".Trim()
} else {
$monitorInfo = "$mfgPrefix $hwID".Trim()
}
}
} catch { $monitorInfo = "Integrated Monitor" }
# 8. Network Info
$networkConfigs = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }
$activeNet = $networkConfigs | Where-Object { $_.IPAddress -notlike "169.254.*" } | Select-Object -First 1
# 9. Storage Info
$disks = Get-CimInstance Win32_DiskDrive | Where-Object { $_.Model -notmatch "Virtual|Msft" }
# --- OUTPUT REPORT ---
Write-Host " [💻] GENERAL INFO" -ForegroundColor White
Write-Host " System Manufacturer (DMI): $($computerSystem.Manufacturer)" -ForegroundColor Gray
Write-Host " Computer Type: $computerFullModel" -ForegroundColor Gray
Write-Host " OS: $($os.Caption) ($displayVersion) $architecture" -ForegroundColor Gray
Write-Host " Kernel: WIN32_NT $osVersion" -ForegroundColor Gray
Write-Host " User: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name.Split('\')[1])" -ForegroundColor Gray
Write-Host " Host/Domain: $($computerSystem.Name)" -ForegroundColor Gray
Write-Host " Serial (S/N): $($bios.SerialNumber)" -ForegroundColor Gray
Write-Host " DirectX: $dxCapability (Hardware Support)" -ForegroundColor Gray
Write-Host " Monitor: $monitorInfo" -ForegroundColor Gray
Write-Host "`n [🔌] MOTHERBOARD & CPU" -ForegroundColor White
Write-Host " CPU: $($processor.Name)" -ForegroundColor Gray
Write-Host " Motherboard: $($computerSystem.Model)" -ForegroundColor Gray
Write-Host " Chipset: $chipsetInfo" -ForegroundColor Gray
Write-Host " RAM: $ramTotalGB GB ($memoryType @ $($ramSpeed)MHz)" -ForegroundColor Gray
Write-Host " BIOS Version: $($bios.SMBIOSBIOSVersion) ($($bios.ReleaseDate.ToString('MM/dd/yyyy')))" -ForegroundColor Gray
Write-Host "`n [🎮] GRAPHICS (GPU)" -ForegroundColor White
foreach ($gpu in $gpus) {
$vram = if ($gpu.AdapterRAM) { [math]::Round($gpu.AdapterRAM / 1MB) } else { 0 }
$gpuType = if ($gpu.Caption -match "Intel|UHD|Iris|AMD Radeon|Basic Render") { "Integrated" } else { "Dedicated" }
Write-Host " GPU: $($gpu.Caption) ($vram MiB) " -NoNewline -ForegroundColor Gray
Write-Host "[$gpuType]" -ForegroundColor Yellow
}
Write-Host "`n [📦] STORAGE" -ForegroundColor White
foreach ($disk in $disks) {
$sizeGB = [math]::Round($disk.Size / 1GB)
Write-Host " Disk: $($disk.Model) ($sizeGB GB)" -NoNewline -ForegroundColor Gray
if ($disk.Model -notmatch "QEMU") {
$type = "HDD SATA"
if ($disk.Model -match "NVMe" -or $disk.InterfaceType -eq "NVMe") { $type = "SSD NVMe" }
elseif ($disk.Model -match "SSD" -or $disk.Caption -match "SSD") { $type = "SSD SATA" }
Write-Host " -> " -NoNewline -ForegroundColor Gray
Write-Host "$type" -ForegroundColor Yellow
} else { Write-Host "" }
}
Write-Host "`n [🌐] NETWORK" -ForegroundColor White
if ($activeNet) {
$ip = $activeNet.IPAddress | Where-Object { $_ -match "\." } | Select-Object -First 1
Write-Host " Main IP: $ip" -ForegroundColor Gray
Write-Host " MAC Address: $($activeNet.MACAddress)" -ForegroundColor Gray
Write-Host " Adapter: $($activeNet.Description)" -ForegroundColor Gray
}
# --- 10. APPLYING OEM INFORMATION TO REGISTRY ---
Write-Host "`n [📝] UPDATING OEM INFORMATION..." -ForegroundColor Cyan
$oemPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation"
# Conditional Manufacturer Logic
if ($isVM -or $isServer) {
$oemManufacturer = $computerSystem.Manufacturer
} else {
# Combines Manufacturer and Model for physical consumer/business PCs
$oemManufacturer = "$($computerSystem.Manufacturer) $($computerSystem.Model)".Trim()
}
# Logic for Model: Serial or Computer Type
$serial = $bios.SerialNumber
$oemModel = if ([string]::IsNullOrWhiteSpace($serial) -or $serial -match "To be filled|Default|None|00000000") { $computerFullModel } else { $serial }
try {
if (-not (Test-Path $oemPath)) { New-Item -Path $oemPath -Force | Out-Null }
Set-ItemProperty -Path $oemPath -Name "Manufacturer" -Value $oemManufacturer
Set-ItemProperty -Path $oemPath -Name "Model" -Value $oemModel
Set-ItemProperty -Path $oemPath -Name "SupportHours" -Value ""
Set-ItemProperty -Path $oemPath -Name "SupportPhone" -Value ""
Set-ItemProperty -Path $oemPath -Name "SupportURL" -Value ""
Write-Host " [✅] OEM Registry updated successfully!" -ForegroundColor Green
} catch {
Write-Host " [❌] Failed to update Registry. Run as Administrator." -ForegroundColor Red
}
Write-Host "`n-- Scan Complete." -ForegroundColor Cyan
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host ""
##------------------------------------------------------##
<#
.SYNOPSIS
Advanced Microsoft Activation Status Professional Audit.
.DESCRIPTION
Fully automated identification for Windows, Office, Project, and Visio.
#>
$FormatEnumerationLimit = -1
Write-Host "--- Microsoft Activation Status Professional Audit ---" -ForegroundColor Cyan
function Get-ActivationStatus {
# Fetch products that have a partial key installed
$Products = Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object { $_.PartialProductKey }
$OS = Get-CimInstance -ClassName Win32_OperatingSystem
# 1. WINDOWS OS ANALYSIS
$WinHeader = "[ WINDOWS OS ]"
# PadRight ensures the background color forms a solid bar and doesn't bleed
Write-Host "`n$($WinHeader.PadRight(65))" -ForegroundColor White -BackgroundColor DarkBlue
$WinOS = $Products | Where-Object { $_.ApplicationID -eq "55c92734-d682-4d71-983e-d6ec3f16059f" }
foreach ($obj in $WinOS) {
$status = if ($obj.LicenseStatus -eq 1) { "Licensed (Activated)" } else { "Unlicensed/Notification" }
$color = if ($obj.LicenseStatus -eq 1) { "Green" } else { "Red" }
$channel = "Unknown"
if ($obj.Description -match "RETAIL") { $channel = "Retail" }
elseif ($obj.Description -match "OEM") { $channel = "OEM" }
elseif ($obj.Description -match "VOLUME_KMS") { $channel = "Volume: KMS" }
elseif ($obj.Description -match "VOLUME_MAK") { $channel = "Volume: MAK" }
$isPermanent = if ($obj.LicenseStatus -eq 1 -and ($obj.GracePeriodRemaining -eq 0 -or $obj.GracePeriodRemaining -ge 2147483647)) { $true } else { $false }
$displayVer = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -ErrorAction SilentlyContinue).DisplayVersion
$fullOSName = "$($OS.Caption) ($displayVer) Build $($OS.BuildNumber) [x$((Get-CimInstance Win32_Processor).AddressWidth)]"
Write-Host "Product: $fullOSName"
Write-Host "Channel: $channel" -ForegroundColor Cyan
Write-Host "Status: " -NoNewline; Write-Host $status -ForegroundColor $color
Write-Host "Partial Key: $($obj.PartialProductKey)"
Write-Host "Permanency: " -NoNewline
if ($isPermanent) { Write-Host "Permanently Activated" -ForegroundColor Green }
else { Write-Host "Temporary ($([math]::Round($obj.GracePeriodRemaining / 1440, 2)) days remaining)" -ForegroundColor Yellow }
}
# 2. OFFICE / PROJECT / VISIO ANALYSIS
$OfficeProducts = $Products | Where-Object { $_.Description -match "Office" -or $_.Name -match "Office" }
if ($OfficeProducts) {
foreach ($off in $OfficeProducts) {
$skuName = $off.Name -replace " edition", ""
$category = "MICROSOFT OFFICE"
$bgColor = "DarkMagenta"
if ($skuName -match "Project") {
$category = "MICROSOFT PROJECT"
$bgColor = "DarkGreen"
}
elseif ($skuName -match "Visio") {
$category = "MICROSOFT VISIO"
$bgColor = "DarkCyan"
}
# Padding correction: PadRight fills the line buffer to prevent color overflow
$OffHeader = "[ $category ]"
Write-Host "`n$($OffHeader.PadRight(65))" -ForegroundColor White -BackgroundColor $bgColor
$offStatus = if ($off.LicenseStatus -eq 1) { "Licensed" } else { "Unlicensed/Grace" }
$offColor = if ($off.LicenseStatus -eq 1) { "Green" } else { "Yellow" }
$offChannel = "Unknown"
if ($off.Description -match "RETAIL") { $offChannel = "Retail" }
elseif ($off.Description -match "OEM") { $offChannel = "OEM" }
elseif ($off.Description -match "VOLUME_KMS" -or $off.Name -match "KMS") { $offChannel = "Volume: KMS" }
elseif ($off.Description -match "VOLUME_MAK" -or $off.Name -match "MAK") { $offChannel = "Volume: MAK" }
$isOffPermanent = if ($off.LicenseStatus -eq 1 -and ($off.GracePeriodRemaining -eq 0 -or $off.GracePeriodRemaining -ge 2147483647)) { $true } else { $false }
Write-Host "Edition: $skuName" -ForegroundColor White
Write-Host "Channel: $offChannel" -ForegroundColor Cyan
Write-Host "Status: " -NoNewline; Write-Host $offStatus -ForegroundColor $offColor
Write-Host "Partial Key: $($off.PartialProductKey)"
Write-Host "Permanency: " -NoNewline
if ($isOffPermanent) { Write-Host "Permanently Activated" -ForegroundColor Green }
else { Write-Host "Temporary ($([math]::Round($off.GracePeriodRemaining / 1440, 2)) days remaining)" -ForegroundColor Yellow }
}
}
}
try {
Get-ActivationStatus
} catch {
Write-Host "Error: Please run PowerShell as Administrator." -ForegroundColor Red
} finally {
# Safe and universal color reset
[Console]::ResetColor()
}
Write-Host "`nAudit Complete." -ForegroundColor Cyan
##------------------------------------------------------##
<#
.SYNOPSIS
Microsoft License Management Tool
.DESCRIPTION
Menu-driven script to manage Windows and Office (including Project/Visio) keys.
Features a 5-second automatic timeout on the main menu.
#>
function Show-LicenseMenu {
Write-Host "`n================================================" -ForegroundColor Cyan
Write-Host " MICROSOFT LICENSE MANAGEMENT TOOL " -ForegroundColor White
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "1. Remove Windows Product Key"
Write-Host "2. Install Windows Product Key"
Write-Host "3. Remove Office / Project / Visio Keys"
Write-Host "4. Skip / Continue Script"
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Select an option (Auto-skip in 5s): " -NoNewline
}
function Remove-WindowsKey {
Write-Host "`nCleaning Windows license state..." -ForegroundColor Yellow
slmgr /cpky
slmgr /upk
slmgr /rilc
Write-Host "Windows license cleared successfully! ✅" -ForegroundColor Green
}
function Install-WindowsKey {
$key = Read-Host "`nEnter the Windows Product Key (XXXXX-XXXXX-XXXXX-XXXXX-XXXXX)"
if ($key -match "([A-Z0-9]{5}-){4}[A-Z0-9]{5}") {
Write-Host "Installing key..." -ForegroundColor Yellow
slmgr /ipk $key
slmgr /ato
} else {
Write-Host "Invalid Key Format!" -ForegroundColor Red
}
}
function Remove-OfficeKeys {
Write-Host "`nScanning for Office/Project/Visio keys..." -ForegroundColor Cyan
$paths = @(
"${env:ProgramFiles}\Microsoft Office\Office16\ospp.vbs",
"${env:ProgramFiles(x86)}\Microsoft Office\Office16\ospp.vbs"
)
$osppPath = $null
foreach ($path in $paths) { if (Test-Path $path) { $osppPath = $path; break } }
if (-not $osppPath) {
Write-Host "ERROR: Office path not found." -ForegroundColor Red
return
}
$status = cscript //nologo "$osppPath" /dstatus
$keys = $status | Select-String "Last 5 characters of installed product key:"
if (-not $keys) {
Write-Host "No Office keys found." -ForegroundColor Yellow
} else {
foreach ($keyLine in $keys) {
$keyFragment = $keyLine.ToString().Split(":")[-1].Trim()
Write-Host "Removing Key: $keyFragment..." -ForegroundColor Yellow
cscript //nologo "$osppPath" /unpkey:$keyFragment | Out-Null
Write-Host "Key $keyFragment removed! ✅" -ForegroundColor Green
}
}
}
# --- Main Menu Execution ---
$timeout = 5
$selection = $null
Show-LicenseMenu
while ($timeout -gt 0) {
if ([console]::KeyAvailable) {
$selection = [console]::ReadKey($true).KeyChar
break
}
Write-Host "..$timeout" -NoNewline -ForegroundColor Gray
Start-Sleep -Seconds 1
$timeout--
}
if ($null -eq $selection -or $timeout -eq 0) {
Write-Host "`n`nTimeout reached. Proceeding to next tasks..." -ForegroundColor Yellow
} else {
switch ($selection) {
'1' { Remove-WindowsKey }
'2' { Install-WindowsKey }
'3' { Remove-OfficeKeys }
'4' { Write-Host "`nSkipping to next tasks..." -ForegroundColor Gray }
Default { Write-Host "`nInvalid selection. Continuing script..." -ForegroundColor Gray }
}
}
# Reset colors and continue
[Console]::ResetColor()
Write-Host "`nProceeding to system optimizations...`n" -ForegroundColor Gray
Write-Host ""
# Clear buffer
while ([console]::KeyAvailable) { [console]::ReadKey($true) | Out-Null }
##------------------------------------------------------##
# --- POWERSHELL 2.0 SECURITY ENFORCER ---
# Purpose: Block PowerShell 2.0 engine to mitigate downgrade attacks.
# Method: Conditional enforcement - only applies fixes if the system is vulnerable.
# --- CONFIGURATION ---
$regTarget = "MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
$regPath = "HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
$valueName = "PSCompatibleVersion"
$secureValue = "3.0, 4.0, 5.0, 5.1"
$cfgFile = "$env:TEMP\sec_template.inf"
$dbFile = "$env:TEMP\sec_audit.sdb"
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host " [🔍] ANALYZING POWERSHELL ENGINE STATUS" -ForegroundColor Cyan
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
$needsFix = $false
# 1. Initial Status Check
if (Test-Path $regPath) {
$initialVal = (Get-ItemProperty -Path $regPath).$valueName
if ($initialVal -notmatch "2.0") {
# --- SYSTEM SECURE: SET FLAG TO FALSE ---
Write-Host " [*] Current Status: " -NoNewline -ForegroundColor White
Write-Host "SECURE" -ForegroundColor Green
Write-Host " [i] Version 2.0 is already blocked. No action required." -ForegroundColor Gray
$needsFix = $false
} else {
# --- SYSTEM VULNERABLE: SET FLAG TO TRUE ---
Write-Host " [*] Current Status: " -NoNewline -ForegroundColor White
Write-Host "VULNERABLE" -ForegroundColor Red
Write-Host " [!] Found Version 2.0 in: $initialVal" -ForegroundColor Yellow
$needsFix = $true
}
} else {
Write-Host " [✅] Target registry path not found. System is secure." -ForegroundColor Green
$needsFix = $false
}
# 2. Execution Logic (Only runs if $needsFix is True)
if ($needsFix) {
Write-Host "`n [⚡] INITIALIZING SECURITY ENFORCEMENT" -ForegroundColor Cyan
Write-Host " ---------------------------------------------------" -ForegroundColor Gray
# Generate Security Template (Granting Full Control to Administrators)
Write-Host " [+] Generating Security Template..." -ForegroundColor Gray
$securityTemplate = @"
[Unicode]
Unicode=yes
[Registry Keys]
"$regTarget",2,"D:AR(A;CI;KA;;;BA)"
[Version]
signature="`$CHICAGO`$"
Revision=1
"@
$securityTemplate | Out-File -FilePath $cfgFile -Encoding unicode
try {
# Apply ACL reset using SecEdit
Write-Host " [+] Resetting Registry Permissions (SecEdit)..." -ForegroundColor Gray
secedit /configure /db $dbFile /cfg $cfgFile /areas REGKEYS /quiet | Out-Null
# Apply the Lockdown Fix
Write-Host " [+] Applying version restriction to registry..." -ForegroundColor Gray
Set-ItemProperty -Path $regPath -Name $valueName -Value $secureValue -Force -ErrorAction Stop
# Final Verification
$finalVal = (Get-ItemProperty -Path $regPath).$valueName
Write-Host "`n [✅] SUCCESS: Security policies applied." -ForegroundColor Green
Write-Host " [i] Updated Value: $finalVal" -ForegroundColor White
}
catch {
Write-Host "`n [❌] CRITICAL ERROR: Could not apply registry fix." -ForegroundColor Red
Write-Host " [!] Reason: $($_.Exception.Message)" -ForegroundColor Yellow
}
finally {
# Cleanup temporary security files
if (Test-Path $cfgFile) { Remove-Item $cfgFile -Force }
if (Test-Path $dbFile) { Remove-Item $dbFile -Force }
}
}
# 3. Final Wrap-up (Always executes, allowing the rest of the script to run)
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host " [🏁] POWERSHELL SECURITY CHECK COMPLETE" -ForegroundColor Green
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host ""
# Keyboard buffer cleanup
while ([console]::KeyAvailable) { [console]::ReadKey($true) | Out-Null }
##------------------------------------------------------##
# --- PRECISION TIME PROTOCOL (NTP) OPTIMIZATION & GUI REGISTRATION ---
# Purpose: Ensures sub-millisecond accuracy, forces service persistence, and registers the server in the Windows GUI.
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host " [🔍] ANALYZING SYSTEM TIME SOURCE & REGISTRY" -ForegroundColor Cyan
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
# --- 1. Infrastructure Check ---
# Ensure Service is not Disabled and is Running (Required for Query)
$timeService = Get-Service w32time -ErrorAction SilentlyContinue
if ($timeService.StartType -eq 'Disabled') {
Write-Host " [!] Windows Time service was Disabled. Re-enabling..." -ForegroundColor Yellow
Set-Service w32time -StartupType Automatic
}
if ($timeService.Status -ne 'Running') {
Write-Host " [!] Starting Windows Time service for analysis..." -ForegroundColor Gray
Start-Service w32time -ErrorAction SilentlyContinue
}
# --- 2. GUI List Registration ---
# This ensures "pool.ntp.org" appears in the Control Panel / Settings dropdown list
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers"
$targetNtp = "pool.ntp.org"
try {
$existingServers = Get-ItemProperty -Path $registryPath
$serverValues = $existingServers.PSObject.Properties.Value
if ($serverValues -notcontains $targetNtp) {
Write-Host " [*] Adding $targetNtp to the Windows GUI selection list..." -ForegroundColor Gray
# Find the next available numerical index in the registry
$currentIndexes = $existingServers.PSObject.Properties.Name | Where-Object { $_ -match '^\d+$' } | ForEach-Object { [int]$_ }
$nextIndex = ($currentIndexes | Measure-Object -Maximum).Maximum + 1
# Create the new registry string value
New-ItemProperty -Path $registryPath -Name $nextIndex -Value $targetNtp -PropertyType String -Force | Out-Null
# Set the newly added server as the "Default" selection in the registry (0-based or index-based)
# Note: Usually (Default) value in this key points to the index to be used.
Set-ItemProperty -Path $registryPath -Name "(Default)" -Value "$nextIndex"
}
} catch {
Write-Host " [!] Failed to update Registry list. Ensure you are running as Admin." -ForegroundColor Red
}
# --- 3. Service Identification & Decision Logic ---
$currentSource = (w32tm /query /source 2>$null)
if ([string]::IsNullOrWhiteSpace($currentSource) -or $currentSource -match "Local CMOS" -or $currentSource -match "Free-Running") {
$displaySource = "Standard/Local Clock"
} else {
$displaySource = $currentSource
}
Write-Host " [*] Current Source: $displaySource" -ForegroundColor White
# Apply changes only if the pool is not already the active source
if ($currentSource -notmatch "pool.ntp.org") {
Write-Host " [!] Optimization required. Configuring pool.ntp.org..." -ForegroundColor Yellow
try {
# Force service to Automatic and Start
Set-Service w32time -StartupType Automatic
Start-Service w32time -ErrorAction SilentlyContinue
# Register network trigger (Service starts when internet is available)
& sc.exe triggerinfo w32time start/networkon stop/networkoff | Out-Null
# Apply global NTP pool configuration with 0x1 flag (Symmetric Active mode)
$ntpPool = "0.pool.ntp.org,0x1 1.pool.ntp.org,0x1 2.pool.ntp.org,0x1 3.pool.ntp.org,0x1"
& w32tm /config /manualpeerlist:"$ntpPool" /syncfromflags:manual /reliable:YES /update | Out-Null
# Restart to commit changes
Restart-Service w32time -Force
# Immediate resync and hardware rediscovery
& w32tm /resync /rediscover | Out-Null
Write-Host "`n [✅] SUCCESS: NTP server updated, registered in GUI, and set to Persistent." -ForegroundColor Green
}
catch {
Write-Host "`n [❌] ERROR: Failed to apply NTP configuration." -ForegroundColor Red
}
}
else {
Write-Host " [✅] SYSTEM ALREADY OPTIMIZED: pool.ntp.org is active and registered." -ForegroundColor Green
}
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host ""
##------------------------------------------------------##
# --- SMBv1 SECURITY ENFORCER (REGISTRY METHOD) ---
# Purpose: Detect and disable the insecure SMBv1 protocol to prevent Ransomware (e.g., WannaCry).
# Method: Direct Registry manipulation for high compatibility with optimized Windows builds.
# --- CONFIGURATION ---
$Smb1Path = "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
$Smb1Value = "SMB1"
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host " [🔍] ANALYZING SMBv1 SERVER STATUS" -ForegroundColor Cyan
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
# 1. Verification Logic
$vulnerable = $false
$abortModule = $false
try {
$currentVal = (Get-ItemProperty -Path $Smb1Path -Name $Smb1Value -ErrorAction SilentlyContinue).$Smb1Value
Write-Host " [*] Current Registry State: " -NoNewline -ForegroundColor White
if ($currentVal -eq 0) {
Write-Host "SECURE" -ForegroundColor Green
Write-Host " [i] SMBv1 is already disabled (Value = 0)." -ForegroundColor Gray
}
elseif ($currentVal -eq 1) {
Write-Host "VULNERABLE" -ForegroundColor Red
Write-Host " [!] SMBv1 is explicitly enabled in registry." -ForegroundColor Yellow
$vulnerable = $true
}
else {
# If the value is missing, Windows may allow SMBv1 by default or via Features.
Write-Host "VULNERABLE (DEFAULT)" -ForegroundColor Red
Write-Host " [!] Registry key 'SMB1' is missing. Protocol is likely active." -ForegroundColor Yellow
$vulnerable = $true
}
} catch {
Write-Host " [❌] ERROR: Could not access LanmanServer registry hive." -ForegroundColor Red
# Setting abort flag instead of 'return' to preserve the main script execution.
$abortModule = $true
}
# 2. Automated Enforcement (Only executes if module wasn't aborted and system is vulnerable)
if (-not $abortModule -and $vulnerable) {
Write-Host "`n [⚡] INITIALIZING SMBv1 DEACTIVATION" -ForegroundColor Cyan
Write-Host " ---------------------------------------------------" -ForegroundColor Gray
try {
# Force create/set the SMB1 value to 0
Write-Host " [+] Injecting 'SMB1' DWord = 0 into registry..." -ForegroundColor Gray
New-ItemProperty -Path $Smb1Path -Name $Smb1Value -Value 0 -PropertyType DWORD -Force -ErrorAction Stop | Out-Null
Write-Host "`n [✅] SUCCESS: SMBv1 Server has been disabled." -ForegroundColor Green
Write-Host " [!] IMPORTANT: A REBOOT is required to apply changes." -ForegroundColor Magenta
}
catch {
Write-Host "`n [❌] FATAL ERROR: Failed to modify registry." -ForegroundColor Red
Write-Host " [i] Reason: $($_.Exception.Message)" -ForegroundColor Yellow
}
} elseif (-not $abortModule -and -not $vulnerable) {
Write-Host "`n [✅] No action needed. Your system is protected against SMBv1 exploits." -ForegroundColor Cyan
}
# 3. Final Summary (Only if access was successful)
if (-not $abortModule) {
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host " [🏁] FINAL STATUS: " -NoNewline -ForegroundColor White
$finalCheck = (Get-ItemProperty -Path $Smb1Path -Name $Smb1Value -ErrorAction SilentlyContinue).$Smb1Value
if ($finalCheck -eq 0) {
Write-Host "PROTECTED" -ForegroundColor Green
} else {
Write-Host "ACTION REQUIRED" -ForegroundColor Red
}
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
}
# Clear keyboard buffer
while ([console]::KeyAvailable) { [console]::ReadKey($true) | Out-Null }
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
Write-Host ""
##------------------------------------------------------##
# --- BITLOCKER PURGE & PRIVACY MANIFEST ---
# Purpose: Deep scan, automatic decryption, and Registry Hardening to restore privacy and performance.
Write-Host "************************************************************" -ForegroundColor Red
Write-Host " BITLOCKER PRIVACY & UTILITY ALERT " -ForegroundColor White -BackgroundColor Red
Write-Host "************************************************************" -ForegroundColor Red
Write-Host "1. ZERO PRIVACY: BitLocker keys are often backed up to MS"
Write-Host " servers automatically. It's a 'black box' encryption where"
Write-Host " your data and keys are accessible to government agencies."
Write-Host "2. PERFORMANCE DRAIN: Constant real-time encryption/decryption"
Write-Host " overhead can reduce SSD R/W speeds by up to 20-45%."
Write-Host "3. RECOVERY TRAP: A BIOS update or hardware change can lock"
Write-Host " you out of your own data forever if the key is lost."
Write-Host "4. INSECURE BY DESIGN: Law enforcement backdoors and DMA"
Write-Host " attacks make it less secure than open-source alternatives."
Write-Host "************************************************************`n" -ForegroundColor Red
# Helper Function to check and set registry with detailed logging
function Set-RegistryIfMissing {
param (
[string]$Path,
[string]$Name,
[uint32]$Value
)
if (-not (Test-Path $Path)) {
New-Item -Path $Path -Force | Out-Null
}
$currentVal = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
if ($null -eq $currentVal -or $currentVal.$Name -ne $Value) {
Write-Host " [APPLIED] $Name = $Value" -ForegroundColor Yellow
Set-ItemProperty -Path $Path -Name $Name -Value $Value -Type DWORD -Force
} else {
Write-Host " [EXISTING] $Name is already set to $Value" -ForegroundColor Gray
}
}
# --- 1. Registry Hardening ---
Write-Host " [🛡️] ANALYZING REGISTRY HARDENING..." -ForegroundColor Cyan
# A. Prevent Automatic Device Encryption
Set-RegistryIfMissing -Path "HKLM:\SYSTEM\CurrentControlSet\Control\BitLocker" -Name "PreventDeviceEncryption" -Value 1
# B. Disable Hardware-Based Encryption
$fvePath = "HKLM:\SOFTWARE\Policies\Microsoft\FVE"
Set-RegistryIfMissing -Path $fvePath -Name "OSHardwareEncryption" -Value 0
Set-RegistryIfMissing -Path $fvePath -Name "OSAllowSoftwareEncryptionFailover" -Value 0
Set-RegistryIfMissing -Path $fvePath -Name "OSRestrictHardwareEncryptionAlgorithms" -Value 0
# C. Disable BitLocker on Removable Drives (BitLocker To Go)
Set-RegistryIfMissing -Path $fvePath -Name "RDVConfigureBDE" -Value 0
Set-RegistryIfMissing -Path $fvePath -Name "RDVAllowBDE" -Value 0
Set-RegistryIfMissing -Path $fvePath -Name "RDVDisableBDE" -Value 0
Write-Host " [✅] Registry check complete." -ForegroundColor Green
# --- 2. Active Decryption Logic ---
Write-Host "`n [🔍] ANALYZING VOLUMES FOR ACTIVE ENCRYPTION..." -ForegroundColor Cyan
try {
$drives = Get-BitLockerVolume | Where-Object { $_.VolumeType -eq 'OperatingSystem' -or $_.VolumeType -eq 'FixedData' }
} catch {
$drives = $null
}
if ($null -eq $drives -or $drives.Count -eq 0) {
Write-Host " [✅] Clean: No active BitLocker volumes detected." -ForegroundColor Green
} else {
foreach ($volume in $drives) {
$driveLetter = $volume.MountPoint
$status = $volume.VolumeStatus
Write-Host " [*] Drive ${driveLetter} Status: $status" -ForegroundColor White
if ($status -ne "FullyDecrypted") {
Write-Host " [!] BitLocker detected on ${driveLetter}. Initiating decryption..." -ForegroundColor Yellow
try {
Disable-BitLocker -MountPoint $driveLetter -ErrorAction Stop
Write-Host " [▶] Decryption started for ${driveLetter}." -ForegroundColor Green
} catch {
Write-Host " [❌] Failed to disable BitLocker on ${driveLetter}: $($_.Exception.Message)" -ForegroundColor Red
}
} else {
Write-Host " [✅] Drive ${driveLetter} is already decrypted and private." -ForegroundColor Green
}
}
}
Write-Host "`nProcess complete! System is now BitLocker-resistant. ✅" -ForegroundColor Green
Write-Host ""
##------------------------------------------------------##
# --- OneDrive Deep Uninstallation with Timeout ---
Write-Host "--------------------------------------------------------" -ForegroundColor Cyan
Write-Host "Checking for OneDrive removal..." -ForegroundColor Cyan
$timeout = 5 # seconds
$wshell = New-Object -ComObject WScript.Shell
$msg = "Do you want to COMPLETELY uninstall OneDrive from this system?`n`n(If you do not answer in $timeout seconds, the answer will be NO)"
$intAnswer = $wshell.Popup($msg, $timeout, "Remove OneDrive?", 4 + 32)
# 6 = Yes | -1 or 7 = Timeout or No
if ($intAnswer -eq 6) {
Write-Host "-- Starting deep uninstallation of OneDrive..." -ForegroundColor Yellow
$ProgressPreference = "SilentlyContinue"
# Kill OneDrive process
Write-Host "-- Closing OneDrive process..." -ForegroundColor Gray
Stop-Process -Name "OneDrive" -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2 # Wait for process to fully release handles
# Run official uninstaller (Check both System32 and SysWOW64)
$uninstallerX86 = "$env:SystemRoot\System32\OneDriveSetup.exe"
$uninstallerX64 = "$env:SystemRoot\SysWOW64\OneDriveSetup.exe"
if (Test-Path $uninstallerX64) {
Write-Host "-- Running official 64-bit uninstaller..." -ForegroundColor Gray
Start-Process -FilePath $uninstallerX64 -ArgumentList "/uninstall" -Wait
} elseif (Test-Path $uninstallerX86) {
Write-Host "-- Running official 32-bit uninstaller..." -ForegroundColor Gray
Start-Process -FilePath $uninstallerX86 -ArgumentList "/uninstall" -Wait
}
# Data Migration (SAFETY FIRST)
Write-Host "-- Migrating OneDrive files to local folders..." -ForegroundColor Gray
if (Test-Path "$env:USERPROFILE\OneDrive") {
# Moves files back to the user root to prevent data loss
robocopy "$env:USERPROFILE\OneDrive" "$env:USERPROFILE" /mov /e /xj /ndl /nfl /njh /njs /nc /ns /np | Out-Null
}
Write-Host "-- Cleaning Registry and Explorer entries..." -ForegroundColor Gray
# Remove from File Explorer Side Panel
Remove-Item -Path "HKCR:\WOW6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "HKCU:\Software\Microsoft\OneDrive" -Recurse -Force -ErrorAction SilentlyContinue
# Anti-reinstallation tweaks (Registry)
Write-Host "-- Applying anti-reinstallation policies..." -ForegroundColor Gray
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive"
if (!(Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null }
Set-ItemProperty -Path $regPath -Name "DisableFileSyncConfig" -Value 1 -Type DWord
Set-ItemProperty -Path $regPath -Name "PreventNetworkUserAccounts" -Value 1 -Type DWord
Write-Host "-- Removing shortcuts and auto-run triggers..." -ForegroundColor Gray
Remove-Item "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Force -ErrorAction SilentlyContinue
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f 2>$null
Get-ScheduledTask -TaskName 'OneDrive*' -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$false -ErrorAction SilentlyContinue
Write-Host "-- Deleting leftover folders..." -ForegroundColor Gray
$folders = @(
"$env:USERPROFILE\OneDrive",
"$env:LOCALAPPDATA\OneDrive",
"$env:LOCALAPPDATA\Microsoft\OneDrive",
"$env:ProgramData\Microsoft OneDrive",
"C:\OneDriveTemp"
)
foreach ($folder in $folders) {
if (Test-Path $folder) {
# Force close any handle and delete
Remove-Item -Path $folder -Recurse -Force -ErrorAction SilentlyContinue
}
}
Write-Host "OneDrive removed and blocked successfully! ✅" -ForegroundColor Green
} else {
Write-Host "OneDrive removal skipped (user declined or timeout). ⏩" -ForegroundColor Yellow
}
Write-Host "--------------------------------------------------------"
##------------------------------------------------------##
# --- Optional Post-Install Scripts (5s Timeout) ---
# 1. StartAllBack Update Blocker
Write-Host "`n--- Optional Tool: StartAllBack Update Blocker ---" -ForegroundColor Cyan
Write-Host "Do you want to run the StartAllBack Update Blocker? [Y/N] (Default: N in 5s): " -NoNewline
# Initialize countdown timer and default answer
$counter = 5
$ans = "n"
# Countdown loop: Checks for key presses every second
while ($counter -gt 0) {
if ([console]::KeyAvailable) {
# Capture the pressed key and stop the timer immediately
$ans = [console]::ReadKey($true).KeyChar
Write-Host " [$ans]" -ForegroundColor White
break
}
Write-Host "..$counter " -NoNewline -ForegroundColor Gray
Start-Sleep -Seconds 1
$counter--
}
# BUFFER FLUSH: Clear any remaining keys from the keyboard buffer.
# This prevents the current input from accidentally skipping the NEXT 5s prompt.
while ([console]::KeyAvailable) { [console]::ReadKey($true) | Out-Null }
# Execute the external script if 'Y' was selected
if ($ans -eq 'y') {
Write-Host "`nExecuting StartAllBack Blocker..." -ForegroundColor Green
# Temporarily allow script execution for the current process
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force | Out-Null
try {
# Download and execute the script directly from GitHub