Skip to content

Instantly share code, notes, and snippets.

@hl2guide
Created January 31, 2022 09:14
Show Gist options
  • Select an option

  • Save hl2guide/45fd3246c6f52b6c8216d2bb4d461fd2 to your computer and use it in GitHub Desktop.

Select an option

Save hl2guide/45fd3246c6f52b6c8216d2bb4d461fd2 to your computer and use it in GitHub Desktop.
A PowerShell script that checks the checksum of one or more linux ISO files for four common Linux distros. Supports: POP!_OS, Mint, Manjaro and Ubuntu.
# A PowerShell script that checks the checksum of one or more linux ISO files for four common Linux distros.
# Supports: POP!_OS, Mint, Manjaro and Ubuntu
# - It's faster and more accurate than manually checking.
# - Be sure to download the ISO files solely from the official sites!
# - To be clear this DOES NOT also check GPG signatures.
$isoFolder = "C:\VMs\ISOs\"
# Checks the ISO folder exists
if(!(Test-Path $isoFolder))
{
$message = "Failed to find the ISOs folder`: $isoFolder"
Write-Host $message -ForegroundColor Yellow
exit
}
# Gets the list of ISO files
$isoFiles = Get-ChildItem -LiteralPath $isoFolder -File -Filter "*.iso"
# No ISOs found
if($isoFiles.Length -eq 0)
{
$message = "Found no ISOs in the folder`: $isoFolder"
Write-Host $message -ForegroundColor Yellow
exit
}
# The array of checksums
$checksumsArray = @(
# Name, Algorithm, Checksum
('*pop-os_21.10_amd64_intel_5.iso', 'SHA256', 'babd581c0fa14fae1b922a5189ae9f9e07f298709f715f6b154806310508891c'),
('*pop-os_21.10_amd64_nvidia_5.iso', 'SHA256', '155701f1547b03294bf8d27e42c81a4a09418b779313fce832bd03fa786b6a41'),
('*pop-os_21.10_arm64_raspi_7.img.xz', 'SHA256', 'b426d9b6a81e940e2bf728b0d2f25997ac6616185aaf80300553f0edc237e9a5'),
('*linuxmint-20.3-cinnamon-64bit-edge.iso' ,'SHA256', 'b6b4bbfafdacf9e00f4c674ba237193b40347140917946cff0ede3b10dc6ea55'),
('*linuxmint-20.3-cinnamon-64bit.iso' ,'SHA256', 'e739317677c2261ae746eee5f1f0662aa319ad0eff260d4eb7055d7c79d10952'),
('*linuxmint-20.3-mate-64bit.iso' ,'SHA256', '27de0b1e6d743d0efc2c193ec88d56a49941ce3e7d58b03730a4bb1895c25be5'),
('*linuxmint-20.3-xfce-64bit.iso' ,'SHA256', '4d37e6a57513d2cdb4a8a993f48a54b18e0d41e86b651326f1101c34460c4719'),
('*ubuntu-18.04.6-desktop-amd64.iso' ,'SHA256', 'f730be589aa1ba923ebe6eca573fa66d09ba14c4c104da2c329df652d42aff11'),
('*ubuntu-18.04.6-live-server-amd64.iso' ,'SHA256', '6c647b1ab4318e8c560d5748f908e108be654bad1e165f7cf4f3c1fc43995934'),
('*ubuntu-21.10-desktop-amd64.iso' ,'SHA256', 'f8d3ab0faeaecb5d26628ae1aa21c9a13e0a242c381aa08157db8624d574b830'),
('*ubuntu-21.10-live-server-amd64.iso' ,'SHA256', 'e84f546dfc6743f24e8b1e15db9cc2d2c698ec57d9adfb852971772d1ce692d4'),
('*manjaro-xfce-21.2.2-220123-linux515.iso' ,'SHA1', 'a15dab73ade326a6863c27bfacb17c91bf0507c7'),
('*manjaro-xfce-21.2.2-minimal-220123-linux515.iso' ,'SHA1', '8b1e33030c0a63f9e9ac8f18b90727f4c0d21e41'),
('*manjaro-xfce-21.2.2-minimal-220123-linux510.iso' ,'SHA1', '90bcf65e283f5bfab80d07541070a8277c1b898e'),
('*manjaro-kde-21.2.2-220123-linux515.iso' ,'SHA1', 'fef430be48f96080237b69426ac76e9496e29df4'),
('*manjaro-kde-21.2.2-minimal-220123-linux515.iso' ,'SHA1', '50922b2d8fc76c887313bd609f7a8c405eb6a0ff'),
('*manjaro-kde-21.2.2-minimal-220123-linux510.iso' ,'SHA1', '9ad15e7157e3bc31697bfba53a7b858d63f09557'),
('*manjaro-gnome-21.2.2-220123-linux515.iso' ,'SHA1', 'b1e6419471c689f02a6bba702ebb1fee4ea72484'),
('*manjaro-gnome-21.2.2-minimal-220123-linux515.iso' ,'SHA1', '36259374ed26dc7645ab87f26931ae1dbbc2b1d2'),
('*manjaro-gnome-21.2.2-minimal-220123-linux510.iso' ,'SHA1', '6dff0b344a00e2e99eaca15b09b6b8361f4b2f0b')
)
# Loops for each ISO file found
foreach($isoFile in $isoFiles)
{
#$isoFile.Name
# Loops Checksum Array
foreach($item in $checksumsArray)
{
# Checks ISO file name is like the item's name (uses *)
if($isoFile.Name -like $item[0])
{
$isoName = $isoFile.Name
$message = "Testing Checksum of ISO ($isoName), please wait.."
Write-Host $message -ForegroundColor Cyan
$isoFullPath = "$isoFolder$isoFile"
$fileHash = Get-FileHash $isoFullPath -Algorithm $item[1]
$fileHash = $fileHash.Hash
#$fileHash
$itemHash = $item[2].ToUpper()
if($fileHash -eq $itemHash)
{
$out = "✅`nISO Name`: $isoName`nISO Hash`: $fileHash`nequals`nRef Hash`: $itemHash"
Write-Host $out -ForegroundColor Green
}
else
{
$out = "❌`nISO Name`: $isoName`nISO Hash`: $fileHash`ndoes not equal`nRef Hash`: $itemHash"
Write-Host $out -ForegroundColor Red
}
#$out = $item[0] + " " + $item[1] + " " + $item[2]
#$out
}
}
}
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment