Skip to content

Instantly share code, notes, and snippets.

@lanekatris
Created August 7, 2015 02:06
Show Gist options
  • Select an option

  • Save lanekatris/49862efa287a27971002 to your computer and use it in GitHub Desktop.

Select an option

Save lanekatris/49862efa287a27971002 to your computer and use it in GitHub Desktop.
# Function / CmdLet that compares the MD5 hash of a file to a expected hash passed in via an argument
# Put in powershell profile ($profile) if you want it as a global function, or put it into a module to be imported
function Check-Hash ($file, $expectedHash)
{
$result = (Get-FileHash $file -Algorithm MD5).Hash.ToLower() -eq $expectedHash.Trim().ToLower()
if ($result -eq $true) {
Write-Host $result -ForegroundColor Green
} else {
Write-Host $result -ForegroundColor Red
}
}
# How to use
# Check-Hash C:\users\User1\Downloads\VMware-converter-en-6.0.0-2716716.exe "f64589b50f416ebf5de547a402b091cb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment