Skip to content

Instantly share code, notes, and snippets.

@MagicAndi
Created May 18, 2015 12:58
Show Gist options
  • Save MagicAndi/5e55ca26be02902d9508 to your computer and use it in GitHub Desktop.
Save MagicAndi/5e55ca26be02902d9508 to your computer and use it in GitHub Desktop.
PowerShell function to compute a MD5 checksum for a file. Based on an answer at http://stackoverflow.com/questions/10521061/how-to-get-an-md5-checksum-in-powershell. Note, this method works for files greater than 2GB in size.
function md5hash($path)
{
$fullPath = Resolve-Path $path
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$file = [System.IO.File]::Open($fullPath,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
[System.BitConverter]::ToString($md5.ComputeHash($file))
$file.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment