Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SMSAgentSoftware/6a6f6dede6533e3aac82380c8df2a074 to your computer and use it in GitHub Desktop.

Select an option

Save SMSAgentSoftware/6a6f6dede6533e3aac82380c8df2a074 to your computer and use it in GitHub Desktop.
Downloads and extracts the bucket hashes from the Microsoft Secure Boot high confidence database in GitHub
############################################################################################################
## Downloads the secure boot high confidence database from GitHub and uploads into our Inventory database ##
############################################################################################################
$highConfidenceDirectory = "C:\Temp\HighConfidenceBuckets"
# Create the directory if it doesn't exist
if (-not (Test-Path -Path $highConfidenceDirectory))
{
$null = New-Item -ItemType Directory -Path $highConfidenceDirectory
}
$ProgressPreference = 'SilentlyContinue'
1..16 | foreach {
$Url = "https://github.com/microsoft/secureboot_objects/raw/refs/heads/main/HighConfidenceBuckets/HighConfidenceBuckets_part$_.csv"
$FileName = "HighConfidenceBuckets_part$_.csv"
Write-Host "Downloading $FileName"
try
{
Invoke-WebRequest -Uri $URL -OutFile "$highConfidenceDirectory\$FileName" -ErrorAction Stop
}
catch
{
Write-Host "Failed to download $FileName`: $_" -ForegroundColor Red
}
}
$downloadedFiles = Get-ChildItem -Path $highConfidenceDirectory -Filter "HighConfidenceBuckets_part*.csv"
$allBucketHashes = [System.Collections.Generic.List[object]]::new()
foreach ($file in $downloadedFiles)
{
Write-Host "Processing $($file.Name)"
try
{
$csvRows = Import-CSV -Path $file.FullName
$allBucketHashes.AddRange($csvRows.BA_BucketId)
}
catch
{
Write-Host "Failed to process $($file.Name)`: $_" -ForegroundColor Red
}
}
Write-Host "Total bucket hashes collected: $($allBucketHashes.Count)" -ForegroundColor Green
Remove-Item -Path $highConfidenceDirectory -Recurse -Force -ErrorAction SilentlyContinue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment