Guest User

test_partition_and_db_v3.ps1

a guest
Feb 12th, 2026
256
0
252 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.95 KB | Cybersecurity | 0 0
  1. <# README
  2.  
  3. Pre-test:
  4. powershell -ExecutionPolicy Bypass D:\test_partition_and_db_v2.ps1
  5.  
  6. Update DB:
  7. reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Secureboot /v AvailableUpdates /t REG_DWORD /d 0x40 /f
  8. Start-ScheduledTask -TaskName "\Microsoft\Windows\PI\Secure-Boot-Update"
  9.  
  10. 2x reboot or brute force, whichever works
  11. test again with line 2
  12.  
  13. Update EFI partition bootloader:
  14. reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Secureboot /v AvailableUpdates /t REG_DWORD /d 0x100 /f
  15. Start-ScheduledTask -TaskName "\Microsoft\Windows\PI\Secure-Boot-Update"
  16.  
  17. 2x reboot or brute force, whichever works
  18. test again with line 2, done #>
  19.  
  20. $PSVersionTable.PSVersion.ToString() + "`n"
  21.  
  22. function Format-Color([hashtable] $Colors = @{}, [switch] $SimpleMatch) {
  23.     $lines = ($input | Out-String) -replace "`r", "" -split "`n"
  24.     foreach($line in $lines) {
  25.         $color = ''
  26.         foreach($pattern in $Colors.Keys){
  27.             if(!$SimpleMatch -and $line -match $pattern) { $color = $Colors[$pattern] }
  28.             elseif ($SimpleMatch -and $line -like $pattern) { $color = $Colors[$pattern] }
  29.         }
  30.         if($color) {
  31.             Write-Host -ForegroundColor 'Green' $line
  32.         } else {
  33.             Write-Host -ForegroundColor 'Red' $line
  34.         }
  35.     }
  36. }
  37.  
  38. echo "Checking FAT32 EFI partition..."
  39. mountvol S: /S
  40. $sig = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate
  41. $sig = [System.Security.Cryptography.X509Certificates.X509Certificate]::CreateFromSignedFile("S:\EFI\Microsoft\Boot\bootmgfw.efi")
  42. $sig2 = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $sig | Select-Object -ExpandProperty 'issuer'
  43. echo $sig2 | Format-Color @{ 'CA 2023' = 'dummy' }
  44. mountvol S: /D
  45.  
  46. echo "Checking SecureBoot DB..."
  47. [System.Text.Encoding]::ASCII.GetString((Get-SecureBootUEFI db).bytes) -match 'Windows UEFI CA 2023' | Format-Color @{ 'True' = 'dummy' }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment