Guest User

test_partition_and_db_v2.ps1

a guest
Feb 11th, 2026
648
0
94 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.29 KB | Cybersecurity | 0 0
  1. $PSVersionTable.PSVersion.ToString() + "`n"
  2.  
  3. function Format-Color([hashtable] $Colors = @{}, [switch] $SimpleMatch) {
  4.     $lines = ($input | Out-String) -replace "`r", "" -split "`n"
  5.     foreach($line in $lines) {
  6.         $color = ''
  7.         foreach($pattern in $Colors.Keys){
  8.             if(!$SimpleMatch -and $line -match $pattern) { $color = $Colors[$pattern] }
  9.             elseif ($SimpleMatch -and $line -like $pattern) { $color = $Colors[$pattern] }
  10.         }
  11.         if($color) {
  12.             Write-Host -ForegroundColor 'Green' $line
  13.         } else {
  14.             Write-Host -ForegroundColor 'Red' $line
  15.         }
  16.     }
  17. }
  18.  
  19. echo "Checking FAT32 EFI partition..."
  20. mountvol S: /S
  21. $sig = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate
  22. $sig = [System.Security.Cryptography.X509Certificates.X509Certificate]::CreateFromSignedFile("S:\EFI\Microsoft\Boot\bootmgfw.efi")
  23. $sig2 = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $sig | Select-Object -ExpandProperty 'issuer'
  24. echo $sig2 | Format-Color @{ 'CA 2023' = 'dummy' }
  25. mountvol S: /D
  26.  
  27. echo "Checking SecureBoot DB..."
  28. [System.Text.Encoding]::ASCII.GetString((Get-SecureBootUEFI db).bytes) -match 'Windows UEFI CA 2023' | Format-Color @{ 'True' = 'dummy' }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment